Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: ipset: Split extensions into separate files

Cleanup to separate all extensions into individual files.

Ported from a patch proposed by Sergey Popovich <popovich_sergei@mail.ua>.

Suggested-by: Sergey Popovich <popovich_sergei@mail.ua>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>

+123 -93
+2 -93
include/linux/netfilter/ipset/ip_set.h
··· 292 292 return nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(cadt_flags)); 293 293 } 294 294 295 - static inline void 296 - ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter) 297 - { 298 - atomic64_add((long long)bytes, &(counter)->bytes); 299 - } 300 - 301 - static inline void 302 - ip_set_add_packets(u64 packets, struct ip_set_counter *counter) 303 - { 304 - atomic64_add((long long)packets, &(counter)->packets); 305 - } 306 - 307 - static inline u64 308 - ip_set_get_bytes(const struct ip_set_counter *counter) 309 - { 310 - return (u64)atomic64_read(&(counter)->bytes); 311 - } 312 - 313 - static inline u64 314 - ip_set_get_packets(const struct ip_set_counter *counter) 315 - { 316 - return (u64)atomic64_read(&(counter)->packets); 317 - } 318 - 319 - static inline void 320 - ip_set_update_counter(struct ip_set_counter *counter, 321 - const struct ip_set_ext *ext, 322 - struct ip_set_ext *mext, u32 flags) 323 - { 324 - if (ext->packets != ULLONG_MAX && 325 - !(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) { 326 - ip_set_add_bytes(ext->bytes, counter); 327 - ip_set_add_packets(ext->packets, counter); 328 - } 329 - if (flags & IPSET_FLAG_MATCH_COUNTERS) { 330 - mext->packets = ip_set_get_packets(counter); 331 - mext->bytes = ip_set_get_bytes(counter); 332 - } 333 - } 334 - 335 - static inline bool 336 - ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter) 337 - { 338 - return nla_put_net64(skb, IPSET_ATTR_BYTES, 339 - cpu_to_be64(ip_set_get_bytes(counter)), 340 - IPSET_ATTR_PAD) || 341 - nla_put_net64(skb, IPSET_ATTR_PACKETS, 342 - cpu_to_be64(ip_set_get_packets(counter)), 343 - IPSET_ATTR_PAD); 344 - } 345 - 346 - static inline void 347 - ip_set_init_counter(struct ip_set_counter *counter, 348 - const struct ip_set_ext *ext) 349 - { 350 - if (ext->bytes != ULLONG_MAX) 351 - atomic64_set(&(counter)->bytes, (long long)(ext->bytes)); 352 - if (ext->packets != ULLONG_MAX) 353 - atomic64_set(&(counter)->packets, (long long)(ext->packets)); 354 - } 355 - 356 - static inline void 357 - ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo, 358 - const struct ip_set_ext *ext, 359 - struct ip_set_ext *mext, u32 flags) 360 - { 361 - mext->skbinfo = *skbinfo; 362 - } 363 - 364 - static inline bool 365 - ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo) 366 - { 367 - /* Send nonzero parameters only */ 368 - return ((skbinfo->skbmark || skbinfo->skbmarkmask) && 369 - nla_put_net64(skb, IPSET_ATTR_SKBMARK, 370 - cpu_to_be64((u64)skbinfo->skbmark << 32 | 371 - skbinfo->skbmarkmask), 372 - IPSET_ATTR_PAD)) || 373 - (skbinfo->skbprio && 374 - nla_put_net32(skb, IPSET_ATTR_SKBPRIO, 375 - cpu_to_be32(skbinfo->skbprio))) || 376 - (skbinfo->skbqueue && 377 - nla_put_net16(skb, IPSET_ATTR_SKBQUEUE, 378 - cpu_to_be16(skbinfo->skbqueue))); 379 - } 380 - 381 - static inline void 382 - ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo, 383 - const struct ip_set_ext *ext) 384 - { 385 - *skbinfo = ext->skbinfo; 386 - } 387 - 388 295 /* Netlink CB args */ 389 296 enum { 390 297 IPSET_CB_NET = 0, /* net namespace */ ··· 446 539 447 540 #include <linux/netfilter/ipset/ip_set_timeout.h> 448 541 #include <linux/netfilter/ipset/ip_set_comment.h> 542 + #include <linux/netfilter/ipset/ip_set_counter.h> 543 + #include <linux/netfilter/ipset/ip_set_skbinfo.h> 449 544 450 545 int 451 546 ip_set_put_extensions(struct sk_buff *skb, const struct ip_set *set,
+75
include/linux/netfilter/ipset/ip_set_counter.h
··· 1 + #ifndef _IP_SET_COUNTER_H 2 + #define _IP_SET_COUNTER_H 3 + 4 + /* Copyright (C) 2015 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + #ifdef __KERNEL__ 12 + 13 + static inline void 14 + ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter) 15 + { 16 + atomic64_add((long long)bytes, &(counter)->bytes); 17 + } 18 + 19 + static inline void 20 + ip_set_add_packets(u64 packets, struct ip_set_counter *counter) 21 + { 22 + atomic64_add((long long)packets, &(counter)->packets); 23 + } 24 + 25 + static inline u64 26 + ip_set_get_bytes(const struct ip_set_counter *counter) 27 + { 28 + return (u64)atomic64_read(&(counter)->bytes); 29 + } 30 + 31 + static inline u64 32 + ip_set_get_packets(const struct ip_set_counter *counter) 33 + { 34 + return (u64)atomic64_read(&(counter)->packets); 35 + } 36 + 37 + static inline void 38 + ip_set_update_counter(struct ip_set_counter *counter, 39 + const struct ip_set_ext *ext, 40 + struct ip_set_ext *mext, u32 flags) 41 + { 42 + if (ext->packets != ULLONG_MAX && 43 + !(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) { 44 + ip_set_add_bytes(ext->bytes, counter); 45 + ip_set_add_packets(ext->packets, counter); 46 + } 47 + if (flags & IPSET_FLAG_MATCH_COUNTERS) { 48 + mext->packets = ip_set_get_packets(counter); 49 + mext->bytes = ip_set_get_bytes(counter); 50 + } 51 + } 52 + 53 + static inline bool 54 + ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter) 55 + { 56 + return nla_put_net64(skb, IPSET_ATTR_BYTES, 57 + cpu_to_be64(ip_set_get_bytes(counter)), 58 + IPSET_ATTR_PAD) || 59 + nla_put_net64(skb, IPSET_ATTR_PACKETS, 60 + cpu_to_be64(ip_set_get_packets(counter)), 61 + IPSET_ATTR_PAD); 62 + } 63 + 64 + static inline void 65 + ip_set_init_counter(struct ip_set_counter *counter, 66 + const struct ip_set_ext *ext) 67 + { 68 + if (ext->bytes != ULLONG_MAX) 69 + atomic64_set(&(counter)->bytes, (long long)(ext->bytes)); 70 + if (ext->packets != ULLONG_MAX) 71 + atomic64_set(&(counter)->packets, (long long)(ext->packets)); 72 + } 73 + 74 + #endif /* __KERNEL__ */ 75 + #endif /* _IP_SET_COUNTER_H */
+46
include/linux/netfilter/ipset/ip_set_skbinfo.h
··· 1 + #ifndef _IP_SET_SKBINFO_H 2 + #define _IP_SET_SKBINFO_H 3 + 4 + /* Copyright (C) 2015 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + #ifdef __KERNEL__ 12 + 13 + static inline void 14 + ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo, 15 + const struct ip_set_ext *ext, 16 + struct ip_set_ext *mext, u32 flags) 17 + { 18 + mext->skbinfo = *skbinfo; 19 + } 20 + 21 + static inline bool 22 + ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo) 23 + { 24 + /* Send nonzero parameters only */ 25 + return ((skbinfo->skbmark || skbinfo->skbmarkmask) && 26 + nla_put_net64(skb, IPSET_ATTR_SKBMARK, 27 + cpu_to_be64((u64)skbinfo->skbmark << 32 | 28 + skbinfo->skbmarkmask), 29 + IPSET_ATTR_PAD)) || 30 + (skbinfo->skbprio && 31 + nla_put_net32(skb, IPSET_ATTR_SKBPRIO, 32 + cpu_to_be32(skbinfo->skbprio))) || 33 + (skbinfo->skbqueue && 34 + nla_put_net16(skb, IPSET_ATTR_SKBQUEUE, 35 + cpu_to_be16(skbinfo->skbqueue))); 36 + } 37 + 38 + static inline void 39 + ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo, 40 + const struct ip_set_ext *ext) 41 + { 42 + *skbinfo = ext->skbinfo; 43 + } 44 + 45 + #endif /* __KERNEL__ */ 46 + #endif /* _IP_SET_SKBINFO_H */