netfilter: Rename ingress hook include file
authorLukas Wunner <lukas@wunner.de>
Wed, 11 Mar 2020 11:59:01 +0000 (12:59 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 18 Mar 2020 00:20:04 +0000 (01:20 +0100)
Prepare for addition of a netfilter egress hook by renaming
<linux/netfilter_ingress.h> to <linux/netfilter_netdev.h>.

The egress hook also necessitates a refactoring of the include file,
but that is done in a separate commit to ease reviewing.

No functional change intended.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter_ingress.h [deleted file]
include/linux/netfilter_netdev.h [new file with mode: 0644]
net/core/dev.c

diff --git a/include/linux/netfilter_ingress.h b/include/linux/netfilter_ingress.h
deleted file mode 100644 (file)
index a13774b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _NETFILTER_INGRESS_H_
-#define _NETFILTER_INGRESS_H_
-
-#include <linux/netfilter.h>
-#include <linux/netdevice.h>
-
-#ifdef CONFIG_NETFILTER_INGRESS
-static inline bool nf_hook_ingress_active(const struct sk_buff *skb)
-{
-#ifdef CONFIG_JUMP_LABEL
-       if (!static_key_false(&nf_hooks_needed[NFPROTO_NETDEV][NF_NETDEV_INGRESS]))
-               return false;
-#endif
-       return rcu_access_pointer(skb->dev->nf_hooks_ingress);
-}
-
-/* caller must hold rcu_read_lock */
-static inline int nf_hook_ingress(struct sk_buff *skb)
-{
-       struct nf_hook_entries *e = rcu_dereference(skb->dev->nf_hooks_ingress);
-       struct nf_hook_state state;
-       int ret;
-
-       /* Must recheck the ingress hook head, in the event it became NULL
-        * after the check in nf_hook_ingress_active evaluated to true.
-        */
-       if (unlikely(!e))
-               return 0;
-
-       nf_hook_state_init(&state, NF_NETDEV_INGRESS,
-                          NFPROTO_NETDEV, skb->dev, NULL, NULL,
-                          dev_net(skb->dev), NULL);
-       ret = nf_hook_slow(skb, &state, e, 0);
-       if (ret == 0)
-               return -1;
-
-       return ret;
-}
-
-static inline void nf_hook_ingress_init(struct net_device *dev)
-{
-       RCU_INIT_POINTER(dev->nf_hooks_ingress, NULL);
-}
-#else /* CONFIG_NETFILTER_INGRESS */
-static inline int nf_hook_ingress_active(struct sk_buff *skb)
-{
-       return 0;
-}
-
-static inline int nf_hook_ingress(struct sk_buff *skb)
-{
-       return 0;
-}
-
-static inline void nf_hook_ingress_init(struct net_device *dev) {}
-#endif /* CONFIG_NETFILTER_INGRESS */
-#endif /* _NETFILTER_INGRESS_H_ */
diff --git a/include/linux/netfilter_netdev.h b/include/linux/netfilter_netdev.h
new file mode 100644 (file)
index 0000000..a13774b
--- /dev/null
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _NETFILTER_INGRESS_H_
+#define _NETFILTER_INGRESS_H_
+
+#include <linux/netfilter.h>
+#include <linux/netdevice.h>
+
+#ifdef CONFIG_NETFILTER_INGRESS
+static inline bool nf_hook_ingress_active(const struct sk_buff *skb)
+{
+#ifdef CONFIG_JUMP_LABEL
+       if (!static_key_false(&nf_hooks_needed[NFPROTO_NETDEV][NF_NETDEV_INGRESS]))
+               return false;
+#endif
+       return rcu_access_pointer(skb->dev->nf_hooks_ingress);
+}
+
+/* caller must hold rcu_read_lock */
+static inline int nf_hook_ingress(struct sk_buff *skb)
+{
+       struct nf_hook_entries *e = rcu_dereference(skb->dev->nf_hooks_ingress);
+       struct nf_hook_state state;
+       int ret;
+
+       /* Must recheck the ingress hook head, in the event it became NULL
+        * after the check in nf_hook_ingress_active evaluated to true.
+        */
+       if (unlikely(!e))
+               return 0;
+
+       nf_hook_state_init(&state, NF_NETDEV_INGRESS,
+                          NFPROTO_NETDEV, skb->dev, NULL, NULL,
+                          dev_net(skb->dev), NULL);
+       ret = nf_hook_slow(skb, &state, e, 0);
+       if (ret == 0)
+               return -1;
+
+       return ret;
+}
+
+static inline void nf_hook_ingress_init(struct net_device *dev)
+{
+       RCU_INIT_POINTER(dev->nf_hooks_ingress, NULL);
+}
+#else /* CONFIG_NETFILTER_INGRESS */
+static inline int nf_hook_ingress_active(struct sk_buff *skb)
+{
+       return 0;
+}
+
+static inline int nf_hook_ingress(struct sk_buff *skb)
+{
+       return 0;
+}
+
+static inline void nf_hook_ingress_init(struct net_device *dev) {}
+#endif /* CONFIG_NETFILTER_INGRESS */
+#endif /* _NETFILTER_INGRESS_H_ */
index d84541c2444640cc9ef2de40421212c13e360784..b1ce1c942b546b877c46aaae5e68a98fbb6889e4 100644 (file)
 #include <linux/if_macvlan.h>
 #include <linux/errqueue.h>
 #include <linux/hrtimer.h>
-#include <linux/netfilter_ingress.h>
+#include <linux/netfilter_netdev.h>
 #include <linux/crash_dump.h>
 #include <linux/sctp.h>
 #include <net/udp_tunnel.h>