]> granicus.if.org Git - ipset/commitdiff
netfilter: ipset: Split extensions into separate files
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 6 May 2015 05:37:04 +0000 (07:37 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 6 May 2015 05:37:04 +0000 (07:37 +0200)
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>
kernel/include/linux/netfilter/ipset/ip_set.h
kernel/include/linux/netfilter/ipset/ip_set_comment.h
kernel/include/linux/netfilter/ipset/ip_set_counter.h [new file with mode: 0644]
kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h [new file with mode: 0644]

index a70712cae7c485baf36c657258de4defd1bd446c..3f5816bb18650caeea1501330580b37ab6fa4dcc 100644 (file)
@@ -289,96 +289,6 @@ ip_set_put_flags(struct sk_buff *skb, struct ip_set *set)
        return nla_put_net32(skb, IPSET_ATTR_CADT_FLAGS, htonl(cadt_flags));
 }
 
-static inline void
-ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
-{
-       atomic64_add((long long)bytes, &(counter)->bytes);
-}
-
-static inline void
-ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
-{
-       atomic64_add((long long)packets, &(counter)->packets);
-}
-
-static inline u64
-ip_set_get_bytes(const struct ip_set_counter *counter)
-{
-       return (u64)atomic64_read(&(counter)->bytes);
-}
-
-static inline u64
-ip_set_get_packets(const struct ip_set_counter *counter)
-{
-       return (u64)atomic64_read(&(counter)->packets);
-}
-
-static inline void
-ip_set_update_counter(struct ip_set_counter *counter,
-                     const struct ip_set_ext *ext,
-                     struct ip_set_ext *mext, u32 flags)
-{
-       if (ext->packets != ULLONG_MAX &&
-           !(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
-               ip_set_add_bytes(ext->bytes, counter);
-               ip_set_add_packets(ext->packets, counter);
-       }
-       if (flags & IPSET_FLAG_MATCH_COUNTERS) {
-               mext->packets = ip_set_get_packets(counter);
-               mext->bytes = ip_set_get_bytes(counter);
-       }
-}
-
-static inline bool
-ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter)
-{
-       return nla_put_net64(skb, IPSET_ATTR_BYTES,
-                            cpu_to_be64(ip_set_get_bytes(counter))) ||
-              nla_put_net64(skb, IPSET_ATTR_PACKETS,
-                            cpu_to_be64(ip_set_get_packets(counter)));
-}
-
-static inline void
-ip_set_init_counter(struct ip_set_counter *counter,
-                   const struct ip_set_ext *ext)
-{
-       if (ext->bytes != ULLONG_MAX)
-               atomic64_set(&(counter)->bytes, (long long)(ext->bytes));
-       if (ext->packets != ULLONG_MAX)
-               atomic64_set(&(counter)->packets, (long long)(ext->packets));
-}
-
-static inline void
-ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo,
-                  const struct ip_set_ext *ext,
-                  struct ip_set_ext *mext, u32 flags)
-{
-       mext->skbinfo = *skbinfo;
-}
-
-static inline bool
-ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo)
-{
-       /* Send nonzero parameters only */
-       return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
-               nla_put_net64(skb, IPSET_ATTR_SKBMARK,
-                             cpu_to_be64((u64)skbinfo->skbmark << 32 |
-                                         skbinfo->skbmarkmask))) ||
-              (skbinfo->skbprio &&
-               nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
-                             cpu_to_be32(skbinfo->skbprio))) ||
-              (skbinfo->skbqueue &&
-               nla_put_net16(skb, IPSET_ATTR_SKBQUEUE,
-                             cpu_to_be16(skbinfo->skbqueue)));
-}
-
-static inline void
-ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo,
-                   const struct ip_set_ext *ext)
-{
-       *skbinfo = ext->skbinfo;
-}
-
 /* Netlink CB args */
 enum {
        IPSET_CB_NET = 0,       /* net namespace */
@@ -534,6 +444,8 @@ bitmap_bytes(u32 a, u32 b)
 
 #include <linux/netfilter/ipset/ip_set_timeout.h>
 #include <linux/netfilter/ipset/ip_set_comment.h>
+#include <linux/netfilter/ipset/ip_set_counter.h>
+#include <linux/netfilter/ipset/ip_set_skbinfo.h>
 
 static inline int
 ip_set_put_extensions(struct sk_buff *skb, const struct ip_set *set,
index 5444b1bbe656ae6595c0fb81bb25cb02fd732bb9..b31169c36d74c864d2b19ed3efb9d6220e52d868 100644 (file)
@@ -69,5 +69,5 @@ ip_set_comment_free(struct ip_set_comment *comment)
        rcu_assign_pointer(comment->c, NULL);
 }
 
-#endif
-#endif
+#endif /* __KERNEL__ */
+#endif /* _IP_SET_COMMENT_H */
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_counter.h b/kernel/include/linux/netfilter/ipset/ip_set_counter.h
new file mode 100644 (file)
index 0000000..d61e0e5
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _IP_SET_COUNTER_H
+#define _IP_SET_COUNTER_H
+
+/* Copyright (C) 2015 Sergey Popovich <popovich_sergei@mail.ua>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifdef __KERNEL__
+
+static inline void
+ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
+{
+       atomic64_add((long long)bytes, &(counter)->bytes);
+}
+
+static inline void
+ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
+{
+       atomic64_add((long long)packets, &(counter)->packets);
+}
+
+static inline u64
+ip_set_get_bytes(const struct ip_set_counter *counter)
+{
+       return (u64)atomic64_read(&(counter)->bytes);
+}
+
+static inline u64
+ip_set_get_packets(const struct ip_set_counter *counter)
+{
+       return (u64)atomic64_read(&(counter)->packets);
+}
+
+static inline void
+ip_set_update_counter(struct ip_set_counter *counter,
+                     const struct ip_set_ext *ext,
+                     struct ip_set_ext *mext, u32 flags)
+{
+       if (ext->packets != ULLONG_MAX &&
+           !(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
+               ip_set_add_bytes(ext->bytes, counter);
+               ip_set_add_packets(ext->packets, counter);
+       }
+       if (flags & IPSET_FLAG_MATCH_COUNTERS) {
+               mext->packets = ip_set_get_packets(counter);
+               mext->bytes = ip_set_get_bytes(counter);
+       }
+}
+
+static inline bool
+ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter)
+{
+       return nla_put_net64(skb, IPSET_ATTR_BYTES,
+                            cpu_to_be64(ip_set_get_bytes(counter))) ||
+              nla_put_net64(skb, IPSET_ATTR_PACKETS,
+                            cpu_to_be64(ip_set_get_packets(counter)));
+}
+
+static inline void
+ip_set_init_counter(struct ip_set_counter *counter,
+                   const struct ip_set_ext *ext)
+{
+       if (ext->bytes != ULLONG_MAX)
+               atomic64_set(&(counter)->bytes, (long long)(ext->bytes));
+       if (ext->packets != ULLONG_MAX)
+               atomic64_set(&(counter)->packets, (long long)(ext->packets));
+}
+
+#endif /* __KERNEL__ */
+#endif /* _IP_SET_COUNTER_H */
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h b/kernel/include/linux/netfilter/ipset/ip_set_skbinfo.h
new file mode 100644 (file)
index 0000000..b03dd6a
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _IP_SET_SKBINFO_H
+#define _IP_SET_SKBINFO_H
+
+/* Copyright (C) 2015 Sergey Popovich <popovich_sergei@mail.ua>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifdef __KERNEL__
+
+static inline void
+ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo,
+                  const struct ip_set_ext *ext,
+                  struct ip_set_ext *mext, u32 flags)
+{
+       mext->skbinfo = *skbinfo;
+}
+
+static inline bool
+ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo)
+{
+       /* Send nonzero parameters only */
+       return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
+               nla_put_net64(skb, IPSET_ATTR_SKBMARK,
+                             cpu_to_be64((u64)skbinfo->skbmark << 32 |
+                                         skbinfo->skbmarkmask))) ||
+              (skbinfo->skbprio &&
+               nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
+                             cpu_to_be32(skbinfo->skbprio))) ||
+              (skbinfo->skbqueue &&
+               nla_put_net16(skb, IPSET_ATTR_SKBQUEUE,
+                             cpu_to_be16(skbinfo->skbqueue)));
+}
+
+static inline void
+ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo,
+                   const struct ip_set_ext *ext)
+{
+       *skbinfo = ext->skbinfo;
+}
+
+#endif /* __KERNEL__ */
+#endif /* _IP_SET_SKBINFO_H */