@@ -289,37 +289,6 @@ bitmap_ipmac_same_set(const struct ip_set *a, const struct ip_set *b)
289289
290290/* Plain variant */
291291
292- /* Timeout variant */
293-
294- struct bitmap_ipmact_elem {
295- struct {
296- unsigned char ether [ETH_ALEN ];
297- unsigned char filled ;
298- } __attribute__ ((aligned ));
299- unsigned long timeout ;
300- };
301-
302- /* Plain variant with counter */
303-
304- struct bitmap_ipmacc_elem {
305- struct {
306- unsigned char ether [ETH_ALEN ];
307- unsigned char filled ;
308- } __attribute__ ((aligned ));
309- struct ip_set_counter counter ;
310- };
311-
312- /* Timeout variant with counter */
313-
314- struct bitmap_ipmacct_elem {
315- struct {
316- unsigned char ether [ETH_ALEN ];
317- unsigned char filled ;
318- } __attribute__ ((aligned ));
319- unsigned long timeout ;
320- struct ip_set_counter counter ;
321- };
322-
323292#include "ip_set_bitmap_gen.h"
324293
325294/* Create bitmap:ip,mac type of sets */
@@ -328,7 +297,7 @@ static bool
328297init_map_ipmac (struct ip_set * set , struct bitmap_ipmac * map ,
329298 u32 first_ip , u32 last_ip , u32 elements )
330299{
331- map -> members = ip_set_alloc (( last_ip - first_ip + 1 ) * set -> dsize );
300+ map -> members = ip_set_alloc (map -> memsize );
332301 if (!map -> members )
333302 return false;
334303 if (set -> dsize ) {
@@ -353,7 +322,7 @@ static int
353322bitmap_ipmac_create (struct ip_set * set , struct nlattr * tb [],
354323 u32 flags )
355324{
356- u32 first_ip = 0 , last_ip = 0 , cadt_flags = 0 ;
325+ u32 first_ip = 0 , last_ip = 0 ;
357326 u64 elements ;
358327 struct bitmap_ipmac * map ;
359328 int ret ;
@@ -397,57 +366,15 @@ bitmap_ipmac_create(struct ip_set *set, struct nlattr *tb[],
397366
398367 map -> memsize = bitmap_bytes (0 , elements - 1 );
399368 set -> variant = & bitmap_ipmac ;
400- if (tb [IPSET_ATTR_CADT_FLAGS ])
401- cadt_flags = ip_set_get_h32 (tb [IPSET_ATTR_CADT_FLAGS ]);
402- if (cadt_flags & IPSET_FLAG_WITH_COUNTERS ) {
403- set -> extensions |= IPSET_EXT_COUNTER ;
404- if (tb [IPSET_ATTR_TIMEOUT ]) {
405- set -> dsize = sizeof (struct bitmap_ipmacct_elem );
406- set -> offset [IPSET_EXT_ID_TIMEOUT ] =
407- offsetof(struct bitmap_ipmacct_elem , timeout );
408- set -> offset [IPSET_EXT_ID_COUNTER ] =
409- offsetof(struct bitmap_ipmacct_elem , counter );
410-
411- if (!init_map_ipmac (set , map , first_ip , last_ip ,
412- elements )) {
413- kfree (map );
414- return - ENOMEM ;
415- }
416- set -> timeout = ip_set_timeout_uget (
417- tb [IPSET_ATTR_TIMEOUT ]);
418- set -> extensions |= IPSET_EXT_TIMEOUT ;
419- bitmap_ipmac_gc_init (set , bitmap_ipmac_gc );
420- } else {
421- set -> dsize = sizeof (struct bitmap_ipmacc_elem );
422- set -> offset [IPSET_EXT_ID_COUNTER ] =
423- offsetof(struct bitmap_ipmacc_elem , counter );
424-
425- if (!init_map_ipmac (set , map , first_ip , last_ip ,
426- elements )) {
427- kfree (map );
428- return - ENOMEM ;
429- }
430- }
431- } else if (tb [IPSET_ATTR_TIMEOUT ]) {
432- set -> dsize = sizeof (struct bitmap_ipmact_elem );
433- set -> offset [IPSET_EXT_ID_TIMEOUT ] =
434- offsetof(struct bitmap_ipmact_elem , timeout );
435-
436- if (!init_map_ipmac (set , map , first_ip , last_ip , elements )) {
437- kfree (map );
438- return - ENOMEM ;
439- }
369+ set -> dsize = ip_set_elem_len (set , tb ,
370+ sizeof (struct bitmap_ipmac_elem ));
371+ if (!init_map_ipmac (set , map , first_ip , last_ip , elements )) {
372+ kfree (map );
373+ return - ENOMEM ;
374+ }
375+ if (tb [IPSET_ATTR_TIMEOUT ]) {
440376 set -> timeout = ip_set_timeout_uget (tb [IPSET_ATTR_TIMEOUT ]);
441- set -> extensions |= IPSET_EXT_TIMEOUT ;
442377 bitmap_ipmac_gc_init (set , bitmap_ipmac_gc );
443- } else {
444- set -> dsize = sizeof (struct bitmap_ipmac_elem );
445-
446- if (!init_map_ipmac (set , map , first_ip , last_ip , elements )) {
447- kfree (map );
448- return - ENOMEM ;
449- }
450- set -> variant = & bitmap_ipmac ;
451378 }
452379 return 0 ;
453380}
0 commit comments