aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-04-03 20:32:56 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-04 12:31:38 -0400
commit238e54c9cb9385a1ba99e92801f3615a2fb398b6 (patch)
tree4efeb9b5c92f87028a6d321c7088b9d1e270360a
parent1d1de89b9a4746f1dd055a3b8d073dd2f962a3b6 (diff)
netfilter: Make nf_hookfn use nf_hook_state.
Pass the nf_hook_state all the way down into the hook functions themselves. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netfilter.h4
-rw-r--r--net/bridge/br_netfilter.c46
-rw-r--r--net/bridge/netfilter/ebtable_filter.c14
-rw-r--r--net/bridge/netfilter/ebtable_nat.c14
-rw-r--r--net/bridge/netfilter/nf_tables_bridge.c10
-rw-r--r--net/decnet/netfilter/dn_rtmsg.c4
-rw-r--r--net/ipv4/netfilter/arptable_filter.c7
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c10
-rw-r--r--net/ipv4/netfilter/ipt_SYNPROXY.c6
-rw-r--r--net/ipv4/netfilter/iptable_filter.c7
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c14
-rw-r--r--net/ipv4/netfilter/iptable_nat.c28
-rw-r--r--net/ipv4/netfilter/iptable_raw.c8
-rw-r--r--net/ipv4/netfilter/iptable_security.c8
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c20
-rw-r--r--net/ipv4/netfilter/nf_defrag_ipv4.c4
-rw-r--r--net/ipv4/netfilter/nf_tables_arp.c6
-rw-r--r--net/ipv4/netfilter/nf_tables_ipv4.c12
-rw-r--r--net/ipv4/netfilter/nft_chain_nat_ipv4.c25
-rw-r--r--net/ipv4/netfilter/nft_chain_route_ipv4.c6
-rw-r--r--net/ipv6/netfilter/ip6t_SYNPROXY.c6
-rw-r--r--net/ipv6/netfilter/ip6table_filter.c7
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c13
-rw-r--r--net/ipv6/netfilter/ip6table_nat.c28
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c7
-rw-r--r--net/ipv6/netfilter/ip6table_security.c8
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c20
-rw-r--r--net/ipv6/netfilter/nf_defrag_ipv6_hooks.c8
-rw-r--r--net/ipv6/netfilter/nf_tables_ipv6.c12
-rw-r--r--net/ipv6/netfilter/nft_chain_nat_ipv6.c24
-rw-r--r--net/ipv6/netfilter/nft_chain_route_ipv6.c6
-rw-r--r--net/netfilter/core.c3
-rw-r--r--net/netfilter/ipvs/ip_vs_core.c32
-rw-r--r--security/selinux/hooks.c28
-rw-r--r--security/smack/smack_netfilter.c8
35 files changed, 169 insertions, 294 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index aee7ef1e23ed..c480c43ad8f7 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -56,9 +56,7 @@ struct nf_hook_state {
56 56
57typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops, 57typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
58 struct sk_buff *skb, 58 struct sk_buff *skb,
59 const struct net_device *in, 59 const struct nf_hook_state *state);
60 const struct net_device *out,
61 int (*okfn)(struct sk_buff *));
62 60
63struct nf_hook_ops { 61struct nf_hook_ops {
64 struct list_head list; 62 struct list_head list;
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index f3884a1b942f..7527e94dd5dc 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -562,9 +562,7 @@ bad:
562 * to ip6tables, which doesn't support NAT, so things are fairly simple. */ 562 * to ip6tables, which doesn't support NAT, so things are fairly simple. */
563static unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops, 563static unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
564 struct sk_buff *skb, 564 struct sk_buff *skb,
565 const struct net_device *in, 565 const struct nf_hook_state *state)
566 const struct net_device *out,
567 int (*okfn)(struct sk_buff *))
568{ 566{
569 const struct ipv6hdr *hdr; 567 const struct ipv6hdr *hdr;
570 u32 pkt_len; 568 u32 pkt_len;
@@ -612,9 +610,7 @@ static unsigned int br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops,
612 * address to be able to detect DNAT afterwards. */ 610 * address to be able to detect DNAT afterwards. */
613static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops, 611static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
614 struct sk_buff *skb, 612 struct sk_buff *skb,
615 const struct net_device *in, 613 const struct nf_hook_state *state)
616 const struct net_device *out,
617 int (*okfn)(struct sk_buff *))
618{ 614{
619 struct net_bridge_port *p; 615 struct net_bridge_port *p;
620 struct net_bridge *br; 616 struct net_bridge *br;
@@ -623,7 +619,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
623 if (unlikely(!pskb_may_pull(skb, len))) 619 if (unlikely(!pskb_may_pull(skb, len)))
624 return NF_DROP; 620 return NF_DROP;
625 621
626 p = br_port_get_rcu(in); 622 p = br_port_get_rcu(state->in);
627 if (p == NULL) 623 if (p == NULL)
628 return NF_DROP; 624 return NF_DROP;
629 br = p->br; 625 br = p->br;
@@ -633,7 +629,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
633 return NF_ACCEPT; 629 return NF_ACCEPT;
634 630
635 nf_bridge_pull_encap_header_rcsum(skb); 631 nf_bridge_pull_encap_header_rcsum(skb);
636 return br_nf_pre_routing_ipv6(ops, skb, in, out, okfn); 632 return br_nf_pre_routing_ipv6(ops, skb, state);
637 } 633 }
638 634
639 if (!brnf_call_iptables && !br->nf_call_iptables) 635 if (!brnf_call_iptables && !br->nf_call_iptables)
@@ -671,9 +667,7 @@ static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
671 * prevent this from happening. */ 667 * prevent this from happening. */
672static unsigned int br_nf_local_in(const struct nf_hook_ops *ops, 668static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
673 struct sk_buff *skb, 669 struct sk_buff *skb,
674 const struct net_device *in, 670 const struct nf_hook_state *state)
675 const struct net_device *out,
676 int (*okfn)(struct sk_buff *))
677{ 671{
678 br_drop_fake_rtable(skb); 672 br_drop_fake_rtable(skb);
679 return NF_ACCEPT; 673 return NF_ACCEPT;
@@ -710,9 +704,7 @@ static int br_nf_forward_finish(struct sk_buff *skb)
710 * bridge ports. */ 704 * bridge ports. */
711static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops, 705static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
712 struct sk_buff *skb, 706 struct sk_buff *skb,
713 const struct net_device *in, 707 const struct nf_hook_state *state)
714 const struct net_device *out,
715 int (*okfn)(struct sk_buff *))
716{ 708{
717 struct nf_bridge_info *nf_bridge; 709 struct nf_bridge_info *nf_bridge;
718 struct net_device *parent; 710 struct net_device *parent;
@@ -726,7 +718,7 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
726 if (!nf_bridge_unshare(skb)) 718 if (!nf_bridge_unshare(skb))
727 return NF_DROP; 719 return NF_DROP;
728 720
729 parent = bridge_parent(out); 721 parent = bridge_parent(state->out);
730 if (!parent) 722 if (!parent)
731 return NF_DROP; 723 return NF_DROP;
732 724
@@ -754,23 +746,21 @@ static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
754 else 746 else
755 skb->protocol = htons(ETH_P_IPV6); 747 skb->protocol = htons(ETH_P_IPV6);
756 748
757 NF_HOOK(pf, NF_INET_FORWARD, skb, brnf_get_logical_dev(skb, in), parent, 749 NF_HOOK(pf, NF_INET_FORWARD, skb, brnf_get_logical_dev(skb, state->in),
758 br_nf_forward_finish); 750 parent, br_nf_forward_finish);
759 751
760 return NF_STOLEN; 752 return NF_STOLEN;
761} 753}
762 754
763static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops, 755static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
764 struct sk_buff *skb, 756 struct sk_buff *skb,
765 const struct net_device *in, 757 const struct nf_hook_state *state)
766 const struct net_device *out,
767 int (*okfn)(struct sk_buff *))
768{ 758{
769 struct net_bridge_port *p; 759 struct net_bridge_port *p;
770 struct net_bridge *br; 760 struct net_bridge *br;
771 struct net_device **d = (struct net_device **)(skb->cb); 761 struct net_device **d = (struct net_device **)(skb->cb);
772 762
773 p = br_port_get_rcu(out); 763 p = br_port_get_rcu(state->out);
774 if (p == NULL) 764 if (p == NULL)
775 return NF_ACCEPT; 765 return NF_ACCEPT;
776 br = p->br; 766 br = p->br;
@@ -789,9 +779,9 @@ static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
789 nf_bridge_push_encap_header(skb); 779 nf_bridge_push_encap_header(skb);
790 return NF_ACCEPT; 780 return NF_ACCEPT;
791 } 781 }
792 *d = (struct net_device *)in; 782 *d = state->in;
793 NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, skb, (struct net_device *)in, 783 NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, skb, state->in,
794 (struct net_device *)out, br_nf_forward_finish); 784 state->out, br_nf_forward_finish);
795 785
796 return NF_STOLEN; 786 return NF_STOLEN;
797} 787}
@@ -859,9 +849,7 @@ static int br_nf_dev_queue_xmit(struct sk_buff *skb)
859/* PF_BRIDGE/POST_ROUTING ********************************************/ 849/* PF_BRIDGE/POST_ROUTING ********************************************/
860static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops, 850static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
861 struct sk_buff *skb, 851 struct sk_buff *skb,
862 const struct net_device *in, 852 const struct nf_hook_state *state)
863 const struct net_device *out,
864 int (*okfn)(struct sk_buff *))
865{ 853{
866 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 854 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
867 struct net_device *realoutdev = bridge_parent(skb->dev); 855 struct net_device *realoutdev = bridge_parent(skb->dev);
@@ -910,9 +898,7 @@ static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
910 * for the second time. */ 898 * for the second time. */
911static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops, 899static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops,
912 struct sk_buff *skb, 900 struct sk_buff *skb,
913 const struct net_device *in, 901 const struct nf_hook_state *state)
914 const struct net_device *out,
915 int (*okfn)(struct sk_buff *))
916{ 902{
917 if (skb->nf_bridge && 903 if (skb->nf_bridge &&
918 !(skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)) { 904 !(skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)) {
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index ce205aabf9c5..8a3f63b2e807 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -58,20 +58,18 @@ static const struct ebt_table frame_filter = {
58 58
59static unsigned int 59static unsigned int
60ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 60ebt_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
61 const struct net_device *in, const struct net_device *out, 61 const struct nf_hook_state *state)
62 int (*okfn)(struct sk_buff *))
63{ 62{
64 return ebt_do_table(ops->hooknum, skb, in, out, 63 return ebt_do_table(ops->hooknum, skb, state->in, state->out,
65 dev_net(in)->xt.frame_filter); 64 dev_net(state->in)->xt.frame_filter);
66} 65}
67 66
68static unsigned int 67static unsigned int
69ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 68ebt_out_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
70 const struct net_device *in, const struct net_device *out, 69 const struct nf_hook_state *state)
71 int (*okfn)(struct sk_buff *))
72{ 70{
73 return ebt_do_table(ops->hooknum, skb, in, out, 71 return ebt_do_table(ops->hooknum, skb, state->in, state->out,
74 dev_net(out)->xt.frame_filter); 72 dev_net(state->out)->xt.frame_filter);
75} 73}
76 74
77static struct nf_hook_ops ebt_ops_filter[] __read_mostly = { 75static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index a0ac2984fb6c..c5ef5b1ab678 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -58,20 +58,18 @@ static struct ebt_table frame_nat = {
58 58
59static unsigned int 59static unsigned int
60ebt_nat_in(const struct nf_hook_ops *ops, struct sk_buff *skb, 60ebt_nat_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
61 const struct net_device *in, const struct net_device *out, 61 const struct nf_hook_state *state)
62 int (*okfn)(struct sk_buff *))
63{ 62{
64 return ebt_do_table(ops->hooknum, skb, in, out, 63 return ebt_do_table(ops->hooknum, skb, state->in, state->out,
65 dev_net(in)->xt.frame_nat); 64 dev_net(state->in)->xt.frame_nat);
66} 65}
67 66
68static unsigned int 67static unsigned int
69ebt_nat_out(const struct nf_hook_ops *ops, struct sk_buff *skb, 68ebt_nat_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
70 const struct net_device *in, const struct net_device *out, 69 const struct nf_hook_state *state)
71 int (*okfn)(struct sk_buff *))
72{ 70{
73 return ebt_do_table(ops->hooknum, skb, in, out, 71 return ebt_do_table(ops->hooknum, skb, state->in, state->out,
74 dev_net(out)->xt.frame_nat); 72 dev_net(state->out)->xt.frame_nat);
75} 73}
76 74
77static struct nf_hook_ops ebt_ops_nat[] __read_mostly = { 75static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
diff --git a/net/bridge/netfilter/nf_tables_bridge.c b/net/bridge/netfilter/nf_tables_bridge.c
index 19473a9371b8..2c46a47160a8 100644
--- a/net/bridge/netfilter/nf_tables_bridge.c
+++ b/net/bridge/netfilter/nf_tables_bridge.c
@@ -93,21 +93,19 @@ static inline void nft_bridge_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
93static unsigned int 93static unsigned int
94nft_do_chain_bridge(const struct nf_hook_ops *ops, 94nft_do_chain_bridge(const struct nf_hook_ops *ops,
95 struct sk_buff *skb, 95 struct sk_buff *skb,
96 const struct net_device *in, 96 const struct nf_hook_state *state)
97 const struct net_device *out,
98 int (*okfn)(struct sk_buff *))
99{ 97{
100 struct nft_pktinfo pkt; 98 struct nft_pktinfo pkt;
101 99
102 switch (eth_hdr(skb)->h_proto) { 100 switch (eth_hdr(skb)->h_proto) {
103 case htons(ETH_P_IP): 101 case htons(ETH_P_IP):
104 nft_bridge_set_pktinfo_ipv4(&pkt, ops, skb, in, out); 102 nft_bridge_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
105 break; 103 break;
106 case htons(ETH_P_IPV6): 104 case htons(ETH_P_IPV6):
107 nft_bridge_set_pktinfo_ipv6(&pkt, ops, skb, in, out); 105 nft_bridge_set_pktinfo_ipv6(&pkt, ops, skb, state->in, state->out);
108 break; 106 break;
109 default: 107 default:
110 nft_set_pktinfo(&pkt, ops, skb, in, out); 108 nft_set_pktinfo(&pkt, ops, skb, state->in, state->out);
111 break; 109 break;
112 } 110 }
113 111
diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
index e4d9560a910b..af34fc9bdf69 100644
--- a/net/decnet/netfilter/dn_rtmsg.c
+++ b/net/decnet/netfilter/dn_rtmsg.c
@@ -89,9 +89,7 @@ static void dnrmg_send_peer(struct sk_buff *skb)
89 89
90static unsigned int dnrmg_hook(const struct nf_hook_ops *ops, 90static unsigned int dnrmg_hook(const struct nf_hook_ops *ops,
91 struct sk_buff *skb, 91 struct sk_buff *skb,
92 const struct net_device *in, 92 const struct nf_hook_state *state)
93 const struct net_device *out,
94 int (*okfn)(struct sk_buff *))
95{ 93{
96 dnrmg_send_peer(skb); 94 dnrmg_send_peer(skb);
97 return NF_ACCEPT; 95 return NF_ACCEPT;
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index 802ddecb30b8..6a641cb41062 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -28,12 +28,11 @@ static const struct xt_table packet_filter = {
28/* The work comes in here from netfilter.c */ 28/* The work comes in here from netfilter.c */
29static unsigned int 29static unsigned int
30arptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 30arptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
31 const struct net_device *in, const struct net_device *out, 31 const struct nf_hook_state *state)
32 int (*okfn)(struct sk_buff *))
33{ 32{
34 const struct net *net = dev_net((in != NULL) ? in : out); 33 const struct net *net = dev_net(state->in ? state->in : state->out);
35 34
36 return arpt_do_table(skb, ops->hooknum, in, out, 35 return arpt_do_table(skb, ops->hooknum, state->in, state->out,
37 net->ipv4.arptable_filter); 36 net->ipv4.arptable_filter);
38} 37}
39 38
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index f75e9df5e017..771ab3d01ad3 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -504,14 +504,12 @@ static void arp_print(struct arp_payload *payload)
504static unsigned int 504static unsigned int
505arp_mangle(const struct nf_hook_ops *ops, 505arp_mangle(const struct nf_hook_ops *ops,
506 struct sk_buff *skb, 506 struct sk_buff *skb,
507 const struct net_device *in, 507 const struct nf_hook_state *state)
508 const struct net_device *out,
509 int (*okfn)(struct sk_buff *))
510{ 508{
511 struct arphdr *arp = arp_hdr(skb); 509 struct arphdr *arp = arp_hdr(skb);
512 struct arp_payload *payload; 510 struct arp_payload *payload;
513 struct clusterip_config *c; 511 struct clusterip_config *c;
514 struct net *net = dev_net(in ? in : out); 512 struct net *net = dev_net(state->in ? state->in : state->out);
515 513
516 /* we don't care about non-ethernet and non-ipv4 ARP */ 514 /* we don't care about non-ethernet and non-ipv4 ARP */
517 if (arp->ar_hrd != htons(ARPHRD_ETHER) || 515 if (arp->ar_hrd != htons(ARPHRD_ETHER) ||
@@ -536,10 +534,10 @@ arp_mangle(const struct nf_hook_ops *ops,
536 * addresses on different interfacs. However, in the CLUSTERIP case 534 * addresses on different interfacs. However, in the CLUSTERIP case
537 * this wouldn't work, since we didn't subscribe the mcast group on 535 * this wouldn't work, since we didn't subscribe the mcast group on
538 * other interfaces */ 536 * other interfaces */
539 if (c->dev != out) { 537 if (c->dev != state->out) {
540 pr_debug("not mangling arp reply on different " 538 pr_debug("not mangling arp reply on different "
541 "interface: cip'%s'-skb'%s'\n", 539 "interface: cip'%s'-skb'%s'\n",
542 c->dev->name, out->name); 540 c->dev->name, state->out->name);
543 clusterip_config_put(c); 541 clusterip_config_put(c);
544 return NF_ACCEPT; 542 return NF_ACCEPT;
545 } 543 }
diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c
index a313c3fbeb46..e9e67793055f 100644
--- a/net/ipv4/netfilter/ipt_SYNPROXY.c
+++ b/net/ipv4/netfilter/ipt_SYNPROXY.c
@@ -300,11 +300,9 @@ synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par)
300 300
301static unsigned int ipv4_synproxy_hook(const struct nf_hook_ops *ops, 301static unsigned int ipv4_synproxy_hook(const struct nf_hook_ops *ops,
302 struct sk_buff *skb, 302 struct sk_buff *skb,
303 const struct net_device *in, 303 const struct nf_hook_state *nhs)
304 const struct net_device *out,
305 int (*okfn)(struct sk_buff *))
306{ 304{
307 struct synproxy_net *snet = synproxy_pernet(dev_net(in ? : out)); 305 struct synproxy_net *snet = synproxy_pernet(dev_net(nhs->in ? : nhs->out));
308 enum ip_conntrack_info ctinfo; 306 enum ip_conntrack_info ctinfo;
309 struct nf_conn *ct; 307 struct nf_conn *ct;
310 struct nf_conn_synproxy *synproxy; 308 struct nf_conn_synproxy *synproxy;
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
index e08a74a243a8..1df0d42bfd39 100644
--- a/net/ipv4/netfilter/iptable_filter.c
+++ b/net/ipv4/netfilter/iptable_filter.c
@@ -34,8 +34,7 @@ static const struct xt_table packet_filter = {
34 34
35static unsigned int 35static unsigned int
36iptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 36iptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
37 const struct net_device *in, const struct net_device *out, 37 const struct nf_hook_state *state)
38 int (*okfn)(struct sk_buff *))
39{ 38{
40 const struct net *net; 39 const struct net *net;
41 40
@@ -45,8 +44,8 @@ iptable_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
45 /* root is playing with raw sockets. */ 44 /* root is playing with raw sockets. */
46 return NF_ACCEPT; 45 return NF_ACCEPT;
47 46
48 net = dev_net((in != NULL) ? in : out); 47 net = dev_net(state->in ? state->in : state->out);
49 return ipt_do_table(skb, ops->hooknum, in, out, 48 return ipt_do_table(skb, ops->hooknum, state->in, state->out,
50 net->ipv4.iptable_filter); 49 net->ipv4.iptable_filter);
51} 50}
52 51
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index 6a5079c34bb3..7a825e740045 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -81,18 +81,16 @@ ipt_mangle_out(struct sk_buff *skb, const struct net_device *out)
81static unsigned int 81static unsigned int
82iptable_mangle_hook(const struct nf_hook_ops *ops, 82iptable_mangle_hook(const struct nf_hook_ops *ops,
83 struct sk_buff *skb, 83 struct sk_buff *skb,
84 const struct net_device *in, 84 const struct nf_hook_state *state)
85 const struct net_device *out,
86 int (*okfn)(struct sk_buff *))
87{ 85{
88 if (ops->hooknum == NF_INET_LOCAL_OUT) 86 if (ops->hooknum == NF_INET_LOCAL_OUT)
89 return ipt_mangle_out(skb, out); 87 return ipt_mangle_out(skb, state->out);
90 if (ops->hooknum == NF_INET_POST_ROUTING) 88 if (ops->hooknum == NF_INET_POST_ROUTING)
91 return ipt_do_table(skb, ops->hooknum, in, out, 89 return ipt_do_table(skb, ops->hooknum, state->in, state->out,
92 dev_net(out)->ipv4.iptable_mangle); 90 dev_net(state->out)->ipv4.iptable_mangle);
93 /* PREROUTING/INPUT/FORWARD: */ 91 /* PREROUTING/INPUT/FORWARD: */
94 return ipt_do_table(skb, ops->hooknum, in, out, 92 return ipt_do_table(skb, ops->hooknum, state->in, state->out,
95 dev_net(in)->ipv4.iptable_mangle); 93 dev_net(state->in)->ipv4.iptable_mangle);
96} 94}
97 95
98static struct nf_hook_ops *mangle_ops __read_mostly; 96static struct nf_hook_ops *mangle_ops __read_mostly;
diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c
index 6b67d7e9a75d..7a7fea4711e5 100644
--- a/net/ipv4/netfilter/iptable_nat.c
+++ b/net/ipv4/netfilter/iptable_nat.c
@@ -41,38 +41,34 @@ static unsigned int iptable_nat_do_chain(const struct nf_hook_ops *ops,
41 41
42static unsigned int iptable_nat_ipv4_fn(const struct nf_hook_ops *ops, 42static unsigned int iptable_nat_ipv4_fn(const struct nf_hook_ops *ops,
43 struct sk_buff *skb, 43 struct sk_buff *skb,
44 const struct net_device *in, 44 const struct nf_hook_state *state)
45 const struct net_device *out,
46 int (*okfn)(struct sk_buff *))
47{ 45{
48 return nf_nat_ipv4_fn(ops, skb, in, out, iptable_nat_do_chain); 46 return nf_nat_ipv4_fn(ops, skb, state->in, state->out,
47 iptable_nat_do_chain);
49} 48}
50 49
51static unsigned int iptable_nat_ipv4_in(const struct nf_hook_ops *ops, 50static unsigned int iptable_nat_ipv4_in(const struct nf_hook_ops *ops,
52 struct sk_buff *skb, 51 struct sk_buff *skb,
53 const struct net_device *in, 52 const struct nf_hook_state *state)
54 const struct net_device *out,
55 int (*okfn)(struct sk_buff *))
56{ 53{
57 return nf_nat_ipv4_in(ops, skb, in, out, iptable_nat_do_chain); 54 return nf_nat_ipv4_in(ops, skb, state->in, state->out,
55 iptable_nat_do_chain);
58} 56}
59 57
60static unsigned int iptable_nat_ipv4_out(const struct nf_hook_ops *ops, 58static unsigned int iptable_nat_ipv4_out(const struct nf_hook_ops *ops,
61 struct sk_buff *skb, 59 struct sk_buff *skb,
62 const struct net_device *in, 60 const struct nf_hook_state *state)
63 const struct net_device *out,
64 int (*okfn)(struct sk_buff *))
65{ 61{
66 return nf_nat_ipv4_out(ops, skb, in, out, iptable_nat_do_chain); 62 return nf_nat_ipv4_out(ops, skb, state->in, state->out,
63 iptable_nat_do_chain);
67} 64}
68 65
69static unsigned int iptable_nat_ipv4_local_fn(const struct nf_hook_ops *ops, 66static unsigned int iptable_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
70 struct sk_buff *skb, 67 struct sk_buff *skb,
71 const struct net_device *in, 68 const struct nf_hook_state *state)
72 const struct net_device *out,
73 int (*okfn)(struct sk_buff *))
74{ 69{
75 return nf_nat_ipv4_local_fn(ops, skb, in, out, iptable_nat_do_chain); 70 return nf_nat_ipv4_local_fn(ops, skb, state->in, state->out,
71 iptable_nat_do_chain);
76} 72}
77 73
78static struct nf_hook_ops nf_nat_ipv4_ops[] __read_mostly = { 74static struct nf_hook_ops nf_nat_ipv4_ops[] __read_mostly = {
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index b2f7e8f98316..fac8f607c70b 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -21,8 +21,7 @@ static const struct xt_table packet_raw = {
21/* The work comes in here from netfilter.c. */ 21/* The work comes in here from netfilter.c. */
22static unsigned int 22static unsigned int
23iptable_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 23iptable_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
24 const struct net_device *in, const struct net_device *out, 24 const struct nf_hook_state *state)
25 int (*okfn)(struct sk_buff *))
26{ 25{
27 const struct net *net; 26 const struct net *net;
28 27
@@ -32,8 +31,9 @@ iptable_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
32 /* root is playing with raw sockets. */ 31 /* root is playing with raw sockets. */
33 return NF_ACCEPT; 32 return NF_ACCEPT;
34 33
35 net = dev_net((in != NULL) ? in : out); 34 net = dev_net(state->in ? state->in : state->out);
36 return ipt_do_table(skb, ops->hooknum, in, out, net->ipv4.iptable_raw); 35 return ipt_do_table(skb, ops->hooknum, state->in, state->out,
36 net->ipv4.iptable_raw);
37} 37}
38 38
39static struct nf_hook_ops *rawtable_ops __read_mostly; 39static struct nf_hook_ops *rawtable_ops __read_mostly;
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c
index c86647ed2078..d9ad60a57413 100644
--- a/net/ipv4/netfilter/iptable_security.c
+++ b/net/ipv4/netfilter/iptable_security.c
@@ -38,9 +38,7 @@ static const struct xt_table security_table = {
38 38
39static unsigned int 39static unsigned int
40iptable_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 40iptable_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
41 const struct net_device *in, 41 const struct nf_hook_state *state)
42 const struct net_device *out,
43 int (*okfn)(struct sk_buff *))
44{ 42{
45 const struct net *net; 43 const struct net *net;
46 44
@@ -50,8 +48,8 @@ iptable_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
50 /* Somebody is playing with raw sockets. */ 48 /* Somebody is playing with raw sockets. */
51 return NF_ACCEPT; 49 return NF_ACCEPT;
52 50
53 net = dev_net((in != NULL) ? in : out); 51 net = dev_net(state->in ? state->in : state->out);
54 return ipt_do_table(skb, ops->hooknum, in, out, 52 return ipt_do_table(skb, ops->hooknum, state->in, state->out,
55 net->ipv4.iptable_security); 53 net->ipv4.iptable_security);
56} 54}
57 55
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 8c8d6642cbb0..30ad9554b5e9 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -94,9 +94,7 @@ static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
94 94
95static unsigned int ipv4_helper(const struct nf_hook_ops *ops, 95static unsigned int ipv4_helper(const struct nf_hook_ops *ops,
96 struct sk_buff *skb, 96 struct sk_buff *skb,
97 const struct net_device *in, 97 const struct nf_hook_state *state)
98 const struct net_device *out,
99 int (*okfn)(struct sk_buff *))
100{ 98{
101 struct nf_conn *ct; 99 struct nf_conn *ct;
102 enum ip_conntrack_info ctinfo; 100 enum ip_conntrack_info ctinfo;
@@ -123,9 +121,7 @@ static unsigned int ipv4_helper(const struct nf_hook_ops *ops,
123 121
124static unsigned int ipv4_confirm(const struct nf_hook_ops *ops, 122static unsigned int ipv4_confirm(const struct nf_hook_ops *ops,
125 struct sk_buff *skb, 123 struct sk_buff *skb,
126 const struct net_device *in, 124 const struct nf_hook_state *state)
127 const struct net_device *out,
128 int (*okfn)(struct sk_buff *))
129{ 125{
130 struct nf_conn *ct; 126 struct nf_conn *ct;
131 enum ip_conntrack_info ctinfo; 127 enum ip_conntrack_info ctinfo;
@@ -149,24 +145,20 @@ out:
149 145
150static unsigned int ipv4_conntrack_in(const struct nf_hook_ops *ops, 146static unsigned int ipv4_conntrack_in(const struct nf_hook_ops *ops,
151 struct sk_buff *skb, 147 struct sk_buff *skb,
152 const struct net_device *in, 148 const struct nf_hook_state *state)
153 const struct net_device *out,
154 int (*okfn)(struct sk_buff *))
155{ 149{
156 return nf_conntrack_in(dev_net(in), PF_INET, ops->hooknum, skb); 150 return nf_conntrack_in(dev_net(state->in), PF_INET, ops->hooknum, skb);
157} 151}
158 152
159static unsigned int ipv4_conntrack_local(const struct nf_hook_ops *ops, 153static unsigned int ipv4_conntrack_local(const struct nf_hook_ops *ops,
160 struct sk_buff *skb, 154 struct sk_buff *skb,
161 const struct net_device *in, 155 const struct nf_hook_state *state)
162 const struct net_device *out,
163 int (*okfn)(struct sk_buff *))
164{ 156{
165 /* root is playing with raw sockets. */ 157 /* root is playing with raw sockets. */
166 if (skb->len < sizeof(struct iphdr) || 158 if (skb->len < sizeof(struct iphdr) ||
167 ip_hdrlen(skb) < sizeof(struct iphdr)) 159 ip_hdrlen(skb) < sizeof(struct iphdr))
168 return NF_ACCEPT; 160 return NF_ACCEPT;
169 return nf_conntrack_in(dev_net(out), PF_INET, ops->hooknum, skb); 161 return nf_conntrack_in(dev_net(state->out), PF_INET, ops->hooknum, skb);
170} 162}
171 163
172/* Connection tracking may drop packets, but never alters them, so 164/* Connection tracking may drop packets, but never alters them, so
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index 7e5ca6f2d0cd..c88b7d434718 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -63,9 +63,7 @@ static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum,
63 63
64static unsigned int ipv4_conntrack_defrag(const struct nf_hook_ops *ops, 64static unsigned int ipv4_conntrack_defrag(const struct nf_hook_ops *ops,
65 struct sk_buff *skb, 65 struct sk_buff *skb,
66 const struct net_device *in, 66 const struct nf_hook_state *state)
67 const struct net_device *out,
68 int (*okfn)(struct sk_buff *))
69{ 67{
70 struct sock *sk = skb->sk; 68 struct sock *sk = skb->sk;
71 struct inet_sock *inet = inet_sk(skb->sk); 69 struct inet_sock *inet = inet_sk(skb->sk);
diff --git a/net/ipv4/netfilter/nf_tables_arp.c b/net/ipv4/netfilter/nf_tables_arp.c
index 19412a4063fb..fceb50e1e87d 100644
--- a/net/ipv4/netfilter/nf_tables_arp.c
+++ b/net/ipv4/netfilter/nf_tables_arp.c
@@ -17,13 +17,11 @@
17static unsigned int 17static unsigned int
18nft_do_chain_arp(const struct nf_hook_ops *ops, 18nft_do_chain_arp(const struct nf_hook_ops *ops,
19 struct sk_buff *skb, 19 struct sk_buff *skb,
20 const struct net_device *in, 20 const struct nf_hook_state *state)
21 const struct net_device *out,
22 int (*okfn)(struct sk_buff *))
23{ 21{
24 struct nft_pktinfo pkt; 22 struct nft_pktinfo pkt;
25 23
26 nft_set_pktinfo(&pkt, ops, skb, in, out); 24 nft_set_pktinfo(&pkt, ops, skb, state->in, state->out);
27 25
28 return nft_do_chain(&pkt, ops); 26 return nft_do_chain(&pkt, ops);
29} 27}
diff --git a/net/ipv4/netfilter/nf_tables_ipv4.c b/net/ipv4/netfilter/nf_tables_ipv4.c
index 6820c8c40842..708e388e3dbe 100644
--- a/net/ipv4/netfilter/nf_tables_ipv4.c
+++ b/net/ipv4/netfilter/nf_tables_ipv4.c
@@ -20,22 +20,18 @@
20 20
21static unsigned int nft_do_chain_ipv4(const struct nf_hook_ops *ops, 21static unsigned int nft_do_chain_ipv4(const struct nf_hook_ops *ops,
22 struct sk_buff *skb, 22 struct sk_buff *skb,
23 const struct net_device *in, 23 const struct nf_hook_state *state)
24 const struct net_device *out,
25 int (*okfn)(struct sk_buff *))
26{ 24{
27 struct nft_pktinfo pkt; 25 struct nft_pktinfo pkt;
28 26
29 nft_set_pktinfo_ipv4(&pkt, ops, skb, in, out); 27 nft_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
30 28
31 return nft_do_chain(&pkt, ops); 29 return nft_do_chain(&pkt, ops);
32} 30}
33 31
34static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops, 32static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
35 struct sk_buff *skb, 33 struct sk_buff *skb,
36 const struct net_device *in, 34 const struct nf_hook_state *state)
37 const struct net_device *out,
38 int (*okfn)(struct sk_buff *))
39{ 35{
40 if (unlikely(skb->len < sizeof(struct iphdr) || 36 if (unlikely(skb->len < sizeof(struct iphdr) ||
41 ip_hdr(skb)->ihl < sizeof(struct iphdr) / 4)) { 37 ip_hdr(skb)->ihl < sizeof(struct iphdr) / 4)) {
@@ -45,7 +41,7 @@ static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
45 return NF_ACCEPT; 41 return NF_ACCEPT;
46 } 42 }
47 43
48 return nft_do_chain_ipv4(ops, skb, in, out, okfn); 44 return nft_do_chain_ipv4(ops, skb, state);
49} 45}
50 46
51struct nft_af_info nft_af_ipv4 __read_mostly = { 47struct nft_af_info nft_af_ipv4 __read_mostly = {
diff --git a/net/ipv4/netfilter/nft_chain_nat_ipv4.c b/net/ipv4/netfilter/nft_chain_nat_ipv4.c
index df547bf50078..d08db6b0fcc3 100644
--- a/net/ipv4/netfilter/nft_chain_nat_ipv4.c
+++ b/net/ipv4/netfilter/nft_chain_nat_ipv4.c
@@ -41,38 +41,31 @@ static unsigned int nft_nat_do_chain(const struct nf_hook_ops *ops,
41 41
42static unsigned int nft_nat_ipv4_fn(const struct nf_hook_ops *ops, 42static unsigned int nft_nat_ipv4_fn(const struct nf_hook_ops *ops,
43 struct sk_buff *skb, 43 struct sk_buff *skb,
44 const struct net_device *in, 44 const struct nf_hook_state *state)
45 const struct net_device *out,
46 int (*okfn)(struct sk_buff *))
47{ 45{
48 return nf_nat_ipv4_fn(ops, skb, in, out, nft_nat_do_chain); 46 return nf_nat_ipv4_fn(ops, skb, state->in, state->out, nft_nat_do_chain);
49} 47}
50 48
51static unsigned int nft_nat_ipv4_in(const struct nf_hook_ops *ops, 49static unsigned int nft_nat_ipv4_in(const struct nf_hook_ops *ops,
52 struct sk_buff *skb, 50 struct sk_buff *skb,
53 const struct net_device *in, 51 const struct nf_hook_state *state)
54 const struct net_device *out,
55 int (*okfn)(struct sk_buff *))
56{ 52{
57 return nf_nat_ipv4_in(ops, skb, in, out, nft_nat_do_chain); 53 return nf_nat_ipv4_in(ops, skb, state->in, state->out, nft_nat_do_chain);
58} 54}
59 55
60static unsigned int nft_nat_ipv4_out(const struct nf_hook_ops *ops, 56static unsigned int nft_nat_ipv4_out(const struct nf_hook_ops *ops,
61 struct sk_buff *skb, 57 struct sk_buff *skb,
62 const struct net_device *in, 58 const struct nf_hook_state *state)
63 const struct net_device *out,
64 int (*okfn)(struct sk_buff *))
65{ 59{
66 return nf_nat_ipv4_out(ops, skb, in, out, nft_nat_do_chain); 60 return nf_nat_ipv4_out(ops, skb, state->in, state->out, nft_nat_do_chain);
67} 61}
68 62
69static unsigned int nft_nat_ipv4_local_fn(const struct nf_hook_ops *ops, 63static unsigned int nft_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
70 struct sk_buff *skb, 64 struct sk_buff *skb,
71 const struct net_device *in, 65 const struct nf_hook_state *state)
72 const struct net_device *out,
73 int (*okfn)(struct sk_buff *))
74{ 66{
75 return nf_nat_ipv4_local_fn(ops, skb, in, out, nft_nat_do_chain); 67 return nf_nat_ipv4_local_fn(ops, skb, state->in, state->out,
68 nft_nat_do_chain);
76} 69}
77 70
78static const struct nf_chain_type nft_chain_nat_ipv4 = { 71static const struct nf_chain_type nft_chain_nat_ipv4 = {
diff --git a/net/ipv4/netfilter/nft_chain_route_ipv4.c b/net/ipv4/netfilter/nft_chain_route_ipv4.c
index 125b66766c0a..073d0776ae7f 100644
--- a/net/ipv4/netfilter/nft_chain_route_ipv4.c
+++ b/net/ipv4/netfilter/nft_chain_route_ipv4.c
@@ -23,9 +23,7 @@
23 23
24static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops, 24static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
25 struct sk_buff *skb, 25 struct sk_buff *skb,
26 const struct net_device *in, 26 const struct nf_hook_state *state)
27 const struct net_device *out,
28 int (*okfn)(struct sk_buff *))
29{ 27{
30 unsigned int ret; 28 unsigned int ret;
31 struct nft_pktinfo pkt; 29 struct nft_pktinfo pkt;
@@ -39,7 +37,7 @@ static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
39 ip_hdrlen(skb) < sizeof(struct iphdr)) 37 ip_hdrlen(skb) < sizeof(struct iphdr))
40 return NF_ACCEPT; 38 return NF_ACCEPT;
41 39
42 nft_set_pktinfo_ipv4(&pkt, ops, skb, in, out); 40 nft_set_pktinfo_ipv4(&pkt, ops, skb, state->in, state->out);
43 41
44 mark = skb->mark; 42 mark = skb->mark;
45 iph = ip_hdr(skb); 43 iph = ip_hdr(skb);
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index a0d17270117c..6edb7b106de7 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -315,11 +315,9 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
315 315
316static unsigned int ipv6_synproxy_hook(const struct nf_hook_ops *ops, 316static unsigned int ipv6_synproxy_hook(const struct nf_hook_ops *ops,
317 struct sk_buff *skb, 317 struct sk_buff *skb,
318 const struct net_device *in, 318 const struct nf_hook_state *nhs)
319 const struct net_device *out,
320 int (*okfn)(struct sk_buff *))
321{ 319{
322 struct synproxy_net *snet = synproxy_pernet(dev_net(in ? : out)); 320 struct synproxy_net *snet = synproxy_pernet(dev_net(nhs->in ? : nhs->out));
323 enum ip_conntrack_info ctinfo; 321 enum ip_conntrack_info ctinfo;
324 struct nf_conn *ct; 322 struct nf_conn *ct;
325 struct nf_conn_synproxy *synproxy; 323 struct nf_conn_synproxy *synproxy;
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index ca7f6c128086..eb9ef093454f 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -33,12 +33,11 @@ static const struct xt_table packet_filter = {
33/* The work comes in here from netfilter.c. */ 33/* The work comes in here from netfilter.c. */
34static unsigned int 34static unsigned int
35ip6table_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 35ip6table_filter_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
36 const struct net_device *in, const struct net_device *out, 36 const struct nf_hook_state *state)
37 int (*okfn)(struct sk_buff *))
38{ 37{
39 const struct net *net = dev_net((in != NULL) ? in : out); 38 const struct net *net = dev_net(state->in ? state->in : state->out);
40 39
41 return ip6t_do_table(skb, ops->hooknum, in, out, 40 return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
42 net->ipv6.ip6table_filter); 41 net->ipv6.ip6table_filter);
43} 42}
44 43
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index 307bbb782d14..e713b8d3dbbc 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -77,17 +77,16 @@ ip6t_mangle_out(struct sk_buff *skb, const struct net_device *out)
77/* The work comes in here from netfilter.c. */ 77/* The work comes in here from netfilter.c. */
78static unsigned int 78static unsigned int
79ip6table_mangle_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 79ip6table_mangle_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
80 const struct net_device *in, const struct net_device *out, 80 const struct nf_hook_state *state)
81 int (*okfn)(struct sk_buff *))
82{ 81{
83 if (ops->hooknum == NF_INET_LOCAL_OUT) 82 if (ops->hooknum == NF_INET_LOCAL_OUT)
84 return ip6t_mangle_out(skb, out); 83 return ip6t_mangle_out(skb, state->out);
85 if (ops->hooknum == NF_INET_POST_ROUTING) 84 if (ops->hooknum == NF_INET_POST_ROUTING)
86 return ip6t_do_table(skb, ops->hooknum, in, out, 85 return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
87 dev_net(out)->ipv6.ip6table_mangle); 86 dev_net(state->out)->ipv6.ip6table_mangle);
88 /* INPUT/FORWARD */ 87 /* INPUT/FORWARD */
89 return ip6t_do_table(skb, ops->hooknum, in, out, 88 return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
90 dev_net(in)->ipv6.ip6table_mangle); 89 dev_net(state->in)->ipv6.ip6table_mangle);
91} 90}
92 91
93static struct nf_hook_ops *mangle_ops __read_mostly; 92static struct nf_hook_ops *mangle_ops __read_mostly;
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c
index b0634ac996b7..e32b0d0315e6 100644
--- a/net/ipv6/netfilter/ip6table_nat.c
+++ b/net/ipv6/netfilter/ip6table_nat.c
@@ -43,38 +43,34 @@ static unsigned int ip6table_nat_do_chain(const struct nf_hook_ops *ops,
43 43
44static unsigned int ip6table_nat_fn(const struct nf_hook_ops *ops, 44static unsigned int ip6table_nat_fn(const struct nf_hook_ops *ops,
45 struct sk_buff *skb, 45 struct sk_buff *skb,
46 const struct net_device *in, 46 const struct nf_hook_state *state)
47 const struct net_device *out,
48 int (*okfn)(struct sk_buff *))
49{ 47{
50 return nf_nat_ipv6_fn(ops, skb, in, out, ip6table_nat_do_chain); 48 return nf_nat_ipv6_fn(ops, skb, state->in, state->out,
49 ip6table_nat_do_chain);
51} 50}
52 51
53static unsigned int ip6table_nat_in(const struct nf_hook_ops *ops, 52static unsigned int ip6table_nat_in(const struct nf_hook_ops *ops,
54 struct sk_buff *skb, 53 struct sk_buff *skb,
55 const struct net_device *in, 54 const struct nf_hook_state *state)
56 const struct net_device *out,
57 int (*okfn)(struct sk_buff *))
58{ 55{
59 return nf_nat_ipv6_in(ops, skb, in, out, ip6table_nat_do_chain); 56 return nf_nat_ipv6_in(ops, skb, state->in, state->out,
57 ip6table_nat_do_chain);
60} 58}
61 59
62static unsigned int ip6table_nat_out(const struct nf_hook_ops *ops, 60static unsigned int ip6table_nat_out(const struct nf_hook_ops *ops,
63 struct sk_buff *skb, 61 struct sk_buff *skb,
64 const struct net_device *in, 62 const struct nf_hook_state *state)
65 const struct net_device *out,
66 int (*okfn)(struct sk_buff *))
67{ 63{
68 return nf_nat_ipv6_out(ops, skb, in, out, ip6table_nat_do_chain); 64 return nf_nat_ipv6_out(ops, skb, state->in, state->out,
65 ip6table_nat_do_chain);
69} 66}
70 67
71static unsigned int ip6table_nat_local_fn(const struct nf_hook_ops *ops, 68static unsigned int ip6table_nat_local_fn(const struct nf_hook_ops *ops,
72 struct sk_buff *skb, 69 struct sk_buff *skb,
73 const struct net_device *in, 70 const struct nf_hook_state *state)
74 const struct net_device *out,
75 int (*okfn)(struct sk_buff *))
76{ 71{
77 return nf_nat_ipv6_local_fn(ops, skb, in, out, ip6table_nat_do_chain); 72 return nf_nat_ipv6_local_fn(ops, skb, state->in, state->out,
73 ip6table_nat_do_chain);
78} 74}
79 75
80static struct nf_hook_ops nf_nat_ipv6_ops[] __read_mostly = { 76static struct nf_hook_ops nf_nat_ipv6_ops[] __read_mostly = {
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index 5274740acecc..937908e25862 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -20,12 +20,11 @@ static const struct xt_table packet_raw = {
20/* The work comes in here from netfilter.c. */ 20/* The work comes in here from netfilter.c. */
21static unsigned int 21static unsigned int
22ip6table_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 22ip6table_raw_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
23 const struct net_device *in, const struct net_device *out, 23 const struct nf_hook_state *state)
24 int (*okfn)(struct sk_buff *))
25{ 24{
26 const struct net *net = dev_net((in != NULL) ? in : out); 25 const struct net *net = dev_net(state->in ? state->in : state->out);
27 26
28 return ip6t_do_table(skb, ops->hooknum, in, out, 27 return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
29 net->ipv6.ip6table_raw); 28 net->ipv6.ip6table_raw);
30} 29}
31 30
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index ab3b0219ecfa..f33b41e8e294 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -37,13 +37,11 @@ static const struct xt_table security_table = {
37 37
38static unsigned int 38static unsigned int
39ip6table_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, 39ip6table_security_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
40 const struct net_device *in, 40 const struct nf_hook_state *state)
41 const struct net_device *out,
42 int (*okfn)(struct sk_buff *))
43{ 41{
44 const struct net *net = dev_net((in != NULL) ? in : out); 42 const struct net *net = dev_net(state->in ? state->in : state->out);
45 43
46 return ip6t_do_table(skb, ops->hooknum, in, out, 44 return ip6t_do_table(skb, ops->hooknum, state->in, state->out,
47 net->ipv6.ip6table_security); 45 net->ipv6.ip6table_security);
48} 46}
49 47
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index fba91c6fc7ca..4ba0c34c627b 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -97,9 +97,7 @@ static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
97 97
98static unsigned int ipv6_helper(const struct nf_hook_ops *ops, 98static unsigned int ipv6_helper(const struct nf_hook_ops *ops,
99 struct sk_buff *skb, 99 struct sk_buff *skb,
100 const struct net_device *in, 100 const struct nf_hook_state *state)
101 const struct net_device *out,
102 int (*okfn)(struct sk_buff *))
103{ 101{
104 struct nf_conn *ct; 102 struct nf_conn *ct;
105 const struct nf_conn_help *help; 103 const struct nf_conn_help *help;
@@ -135,9 +133,7 @@ static unsigned int ipv6_helper(const struct nf_hook_ops *ops,
135 133
136static unsigned int ipv6_confirm(const struct nf_hook_ops *ops, 134static unsigned int ipv6_confirm(const struct nf_hook_ops *ops,
137 struct sk_buff *skb, 135 struct sk_buff *skb,
138 const struct net_device *in, 136 const struct nf_hook_state *state)
139 const struct net_device *out,
140 int (*okfn)(struct sk_buff *))
141{ 137{
142 struct nf_conn *ct; 138 struct nf_conn *ct;
143 enum ip_conntrack_info ctinfo; 139 enum ip_conntrack_info ctinfo;
@@ -171,25 +167,21 @@ out:
171 167
172static unsigned int ipv6_conntrack_in(const struct nf_hook_ops *ops, 168static unsigned int ipv6_conntrack_in(const struct nf_hook_ops *ops,
173 struct sk_buff *skb, 169 struct sk_buff *skb,
174 const struct net_device *in, 170 const struct nf_hook_state *state)
175 const struct net_device *out,
176 int (*okfn)(struct sk_buff *))
177{ 171{
178 return nf_conntrack_in(dev_net(in), PF_INET6, ops->hooknum, skb); 172 return nf_conntrack_in(dev_net(state->in), PF_INET6, ops->hooknum, skb);
179} 173}
180 174
181static unsigned int ipv6_conntrack_local(const struct nf_hook_ops *ops, 175static unsigned int ipv6_conntrack_local(const struct nf_hook_ops *ops,
182 struct sk_buff *skb, 176 struct sk_buff *skb,
183 const struct net_device *in, 177 const struct nf_hook_state *state)
184 const struct net_device *out,
185 int (*okfn)(struct sk_buff *))
186{ 178{
187 /* root is playing with raw sockets. */ 179 /* root is playing with raw sockets. */
188 if (skb->len < sizeof(struct ipv6hdr)) { 180 if (skb->len < sizeof(struct ipv6hdr)) {
189 net_notice_ratelimited("ipv6_conntrack_local: packet too short\n"); 181 net_notice_ratelimited("ipv6_conntrack_local: packet too short\n");
190 return NF_ACCEPT; 182 return NF_ACCEPT;
191 } 183 }
192 return nf_conntrack_in(dev_net(out), PF_INET6, ops->hooknum, skb); 184 return nf_conntrack_in(dev_net(state->out), PF_INET6, ops->hooknum, skb);
193} 185}
194 186
195static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = { 187static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = {
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index e70382e4dfb5..e2b882056751 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -54,9 +54,7 @@ static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
54 54
55static unsigned int ipv6_defrag(const struct nf_hook_ops *ops, 55static unsigned int ipv6_defrag(const struct nf_hook_ops *ops,
56 struct sk_buff *skb, 56 struct sk_buff *skb,
57 const struct net_device *in, 57 const struct nf_hook_state *state)
58 const struct net_device *out,
59 int (*okfn)(struct sk_buff *))
60{ 58{
61 struct sk_buff *reasm; 59 struct sk_buff *reasm;
62 60
@@ -78,8 +76,8 @@ static unsigned int ipv6_defrag(const struct nf_hook_ops *ops,
78 nf_ct_frag6_consume_orig(reasm); 76 nf_ct_frag6_consume_orig(reasm);
79 77
80 NF_HOOK_THRESH(NFPROTO_IPV6, ops->hooknum, reasm, 78 NF_HOOK_THRESH(NFPROTO_IPV6, ops->hooknum, reasm,
81 (struct net_device *) in, (struct net_device *) out, 79 state->in, state->out,
82 okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1); 80 state->okfn, NF_IP6_PRI_CONNTRACK_DEFRAG + 1);
83 81
84 return NF_STOLEN; 82 return NF_STOLEN;
85} 83}
diff --git a/net/ipv6/netfilter/nf_tables_ipv6.c b/net/ipv6/netfilter/nf_tables_ipv6.c
index 0d812b31277d..224bc8971a0b 100644
--- a/net/ipv6/netfilter/nf_tables_ipv6.c
+++ b/net/ipv6/netfilter/nf_tables_ipv6.c
@@ -18,14 +18,12 @@
18 18
19static unsigned int nft_do_chain_ipv6(const struct nf_hook_ops *ops, 19static unsigned int nft_do_chain_ipv6(const struct nf_hook_ops *ops,
20 struct sk_buff *skb, 20 struct sk_buff *skb,
21 const struct net_device *in, 21 const struct nf_hook_state *state)
22 const struct net_device *out,
23 int (*okfn)(struct sk_buff *))
24{ 22{
25 struct nft_pktinfo pkt; 23 struct nft_pktinfo pkt;
26 24
27 /* malformed packet, drop it */ 25 /* malformed packet, drop it */
28 if (nft_set_pktinfo_ipv6(&pkt, ops, skb, in, out) < 0) 26 if (nft_set_pktinfo_ipv6(&pkt, ops, skb, state->in, state->out) < 0)
29 return NF_DROP; 27 return NF_DROP;
30 28
31 return nft_do_chain(&pkt, ops); 29 return nft_do_chain(&pkt, ops);
@@ -33,9 +31,7 @@ static unsigned int nft_do_chain_ipv6(const struct nf_hook_ops *ops,
33 31
34static unsigned int nft_ipv6_output(const struct nf_hook_ops *ops, 32static unsigned int nft_ipv6_output(const struct nf_hook_ops *ops,
35 struct sk_buff *skb, 33 struct sk_buff *skb,
36 const struct net_device *in, 34 const struct nf_hook_state *state)
37 const struct net_device *out,
38 int (*okfn)(struct sk_buff *))
39{ 35{
40 if (unlikely(skb->len < sizeof(struct ipv6hdr))) { 36 if (unlikely(skb->len < sizeof(struct ipv6hdr))) {
41 if (net_ratelimit()) 37 if (net_ratelimit())
@@ -44,7 +40,7 @@ static unsigned int nft_ipv6_output(const struct nf_hook_ops *ops,
44 return NF_ACCEPT; 40 return NF_ACCEPT;
45 } 41 }
46 42
47 return nft_do_chain_ipv6(ops, skb, in, out, okfn); 43 return nft_do_chain_ipv6(ops, skb, state);
48} 44}
49 45
50struct nft_af_info nft_af_ipv6 __read_mostly = { 46struct nft_af_info nft_af_ipv6 __read_mostly = {
diff --git a/net/ipv6/netfilter/nft_chain_nat_ipv6.c b/net/ipv6/netfilter/nft_chain_nat_ipv6.c
index 1c4b75dd425b..f73f4ae25bc2 100644
--- a/net/ipv6/netfilter/nft_chain_nat_ipv6.c
+++ b/net/ipv6/netfilter/nft_chain_nat_ipv6.c
@@ -39,38 +39,30 @@ static unsigned int nft_nat_do_chain(const struct nf_hook_ops *ops,
39 39
40static unsigned int nft_nat_ipv6_fn(const struct nf_hook_ops *ops, 40static unsigned int nft_nat_ipv6_fn(const struct nf_hook_ops *ops,
41 struct sk_buff *skb, 41 struct sk_buff *skb,
42 const struct net_device *in, 42 const struct nf_hook_state *state)
43 const struct net_device *out,
44 int (*okfn)(struct sk_buff *))
45{ 43{
46 return nf_nat_ipv6_fn(ops, skb, in, out, nft_nat_do_chain); 44 return nf_nat_ipv6_fn(ops, skb, state->in, state->out, nft_nat_do_chain);
47} 45}
48 46
49static unsigned int nft_nat_ipv6_in(const struct nf_hook_ops *ops, 47static unsigned int nft_nat_ipv6_in(const struct nf_hook_ops *ops,
50 struct sk_buff *skb, 48 struct sk_buff *skb,
51 const struct net_device *in, 49 const struct nf_hook_state *state)
52 const struct net_device *out,
53 int (*okfn)(struct sk_buff *))
54{ 50{
55 return nf_nat_ipv6_in(ops, skb, in, out, nft_nat_do_chain); 51 return nf_nat_ipv6_in(ops, skb, state->in, state->out, nft_nat_do_chain);
56} 52}
57 53
58static unsigned int nft_nat_ipv6_out(const struct nf_hook_ops *ops, 54static unsigned int nft_nat_ipv6_out(const struct nf_hook_ops *ops,
59 struct sk_buff *skb, 55 struct sk_buff *skb,
60 const struct net_device *in, 56 const struct nf_hook_state *state)
61 const struct net_device *out,
62 int (*okfn)(struct sk_buff *))
63{ 57{
64 return nf_nat_ipv6_out(ops, skb, in, out, nft_nat_do_chain); 58 return nf_nat_ipv6_out(ops, skb, state->in, state->out, nft_nat_do_chain);
65} 59}
66 60
67static unsigned int nft_nat_ipv6_local_fn(const struct nf_hook_ops *ops, 61static unsigned int nft_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
68 struct sk_buff *skb, 62 struct sk_buff *skb,
69 const struct net_device *in, 63 const struct nf_hook_state *state)
70 const struct net_device *out,
71 int (*okfn)(struct sk_buff *))
72{ 64{
73 return nf_nat_ipv6_local_fn(ops, skb, in, out, nft_nat_do_chain); 65 return nf_nat_ipv6_local_fn(ops, skb, state->in, state->out, nft_nat_do_chain);
74} 66}
75 67
76static const struct nf_chain_type nft_chain_nat_ipv6 = { 68static const struct nf_chain_type nft_chain_nat_ipv6 = {
diff --git a/net/ipv6/netfilter/nft_chain_route_ipv6.c b/net/ipv6/netfilter/nft_chain_route_ipv6.c
index 42031299585e..c826c3c854b2 100644
--- a/net/ipv6/netfilter/nft_chain_route_ipv6.c
+++ b/net/ipv6/netfilter/nft_chain_route_ipv6.c
@@ -24,9 +24,7 @@
24 24
25static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops, 25static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
26 struct sk_buff *skb, 26 struct sk_buff *skb,
27 const struct net_device *in, 27 const struct nf_hook_state *state)
28 const struct net_device *out,
29 int (*okfn)(struct sk_buff *))
30{ 28{
31 unsigned int ret; 29 unsigned int ret;
32 struct nft_pktinfo pkt; 30 struct nft_pktinfo pkt;
@@ -35,7 +33,7 @@ static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
35 u32 mark, flowlabel; 33 u32 mark, flowlabel;
36 34
37 /* malformed packet, drop it */ 35 /* malformed packet, drop it */
38 if (nft_set_pktinfo_ipv6(&pkt, ops, skb, in, out) < 0) 36 if (nft_set_pktinfo_ipv6(&pkt, ops, skb, state->in, state->out) < 0)
39 return NF_DROP; 37 return NF_DROP;
40 38
41 /* save source/dest address, mark, hoplimit, flowlabel, priority */ 39 /* save source/dest address, mark, hoplimit, flowlabel, priority */
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 11d04ebfc5e3..e6163017c42d 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -136,8 +136,7 @@ unsigned int nf_iterate(struct list_head *head,
136 /* Optimization: we don't need to hold module 136 /* Optimization: we don't need to hold module
137 reference here, since function can't sleep. --RR */ 137 reference here, since function can't sleep. --RR */
138repeat: 138repeat:
139 verdict = (*elemp)->hook(*elemp, skb, state->in, state->out, 139 verdict = (*elemp)->hook(*elemp, skb, state);
140 state->okfn);
141 if (verdict != NF_ACCEPT) { 140 if (verdict != NF_ACCEPT) {
142#ifdef CONFIG_NETFILTER_DEBUG 141#ifdef CONFIG_NETFILTER_DEBUG
143 if (unlikely((verdict & NF_VERDICT_MASK) 142 if (unlikely((verdict & NF_VERDICT_MASK)
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 04dbd9c7213f..5d2b806a862e 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1272,8 +1272,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb, int af)
1272 */ 1272 */
1273static unsigned int 1273static unsigned int
1274ip_vs_reply4(const struct nf_hook_ops *ops, struct sk_buff *skb, 1274ip_vs_reply4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1275 const struct net_device *in, const struct net_device *out, 1275 const struct nf_hook_state *state)
1276 int (*okfn)(struct sk_buff *))
1277{ 1276{
1278 return ip_vs_out(ops->hooknum, skb, AF_INET); 1277 return ip_vs_out(ops->hooknum, skb, AF_INET);
1279} 1278}
@@ -1284,8 +1283,7 @@ ip_vs_reply4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1284 */ 1283 */
1285static unsigned int 1284static unsigned int
1286ip_vs_local_reply4(const struct nf_hook_ops *ops, struct sk_buff *skb, 1285ip_vs_local_reply4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1287 const struct net_device *in, const struct net_device *out, 1286 const struct nf_hook_state *state)
1288 int (*okfn)(struct sk_buff *))
1289{ 1287{
1290 return ip_vs_out(ops->hooknum, skb, AF_INET); 1288 return ip_vs_out(ops->hooknum, skb, AF_INET);
1291} 1289}
@@ -1299,8 +1297,7 @@ ip_vs_local_reply4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1299 */ 1297 */
1300static unsigned int 1298static unsigned int
1301ip_vs_reply6(const struct nf_hook_ops *ops, struct sk_buff *skb, 1299ip_vs_reply6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1302 const struct net_device *in, const struct net_device *out, 1300 const struct nf_hook_state *state)
1303 int (*okfn)(struct sk_buff *))
1304{ 1301{
1305 return ip_vs_out(ops->hooknum, skb, AF_INET6); 1302 return ip_vs_out(ops->hooknum, skb, AF_INET6);
1306} 1303}
@@ -1311,8 +1308,7 @@ ip_vs_reply6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1311 */ 1308 */
1312static unsigned int 1309static unsigned int
1313ip_vs_local_reply6(const struct nf_hook_ops *ops, struct sk_buff *skb, 1310ip_vs_local_reply6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1314 const struct net_device *in, const struct net_device *out, 1311 const struct nf_hook_state *state)
1315 int (*okfn)(struct sk_buff *))
1316{ 1312{
1317 return ip_vs_out(ops->hooknum, skb, AF_INET6); 1313 return ip_vs_out(ops->hooknum, skb, AF_INET6);
1318} 1314}
@@ -1769,9 +1765,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
1769 */ 1765 */
1770static unsigned int 1766static unsigned int
1771ip_vs_remote_request4(const struct nf_hook_ops *ops, struct sk_buff *skb, 1767ip_vs_remote_request4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1772 const struct net_device *in, 1768 const struct nf_hook_state *state)
1773 const struct net_device *out,
1774 int (*okfn)(struct sk_buff *))
1775{ 1769{
1776 return ip_vs_in(ops->hooknum, skb, AF_INET); 1770 return ip_vs_in(ops->hooknum, skb, AF_INET);
1777} 1771}
@@ -1782,8 +1776,7 @@ ip_vs_remote_request4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1782 */ 1776 */
1783static unsigned int 1777static unsigned int
1784ip_vs_local_request4(const struct nf_hook_ops *ops, struct sk_buff *skb, 1778ip_vs_local_request4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1785 const struct net_device *in, const struct net_device *out, 1779 const struct nf_hook_state *state)
1786 int (*okfn)(struct sk_buff *))
1787{ 1780{
1788 return ip_vs_in(ops->hooknum, skb, AF_INET); 1781 return ip_vs_in(ops->hooknum, skb, AF_INET);
1789} 1782}
@@ -1796,9 +1789,7 @@ ip_vs_local_request4(const struct nf_hook_ops *ops, struct sk_buff *skb,
1796 */ 1789 */
1797static unsigned int 1790static unsigned int
1798ip_vs_remote_request6(const struct nf_hook_ops *ops, struct sk_buff *skb, 1791ip_vs_remote_request6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1799 const struct net_device *in, 1792 const struct nf_hook_state *state)
1800 const struct net_device *out,
1801 int (*okfn)(struct sk_buff *))
1802{ 1793{
1803 return ip_vs_in(ops->hooknum, skb, AF_INET6); 1794 return ip_vs_in(ops->hooknum, skb, AF_INET6);
1804} 1795}
@@ -1809,8 +1800,7 @@ ip_vs_remote_request6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1809 */ 1800 */
1810static unsigned int 1801static unsigned int
1811ip_vs_local_request6(const struct nf_hook_ops *ops, struct sk_buff *skb, 1802ip_vs_local_request6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1812 const struct net_device *in, const struct net_device *out, 1803 const struct nf_hook_state *state)
1813 int (*okfn)(struct sk_buff *))
1814{ 1804{
1815 return ip_vs_in(ops->hooknum, skb, AF_INET6); 1805 return ip_vs_in(ops->hooknum, skb, AF_INET6);
1816} 1806}
@@ -1829,8 +1819,7 @@ ip_vs_local_request6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1829 */ 1819 */
1830static unsigned int 1820static unsigned int
1831ip_vs_forward_icmp(const struct nf_hook_ops *ops, struct sk_buff *skb, 1821ip_vs_forward_icmp(const struct nf_hook_ops *ops, struct sk_buff *skb,
1832 const struct net_device *in, const struct net_device *out, 1822 const struct nf_hook_state *state)
1833 int (*okfn)(struct sk_buff *))
1834{ 1823{
1835 int r; 1824 int r;
1836 struct net *net; 1825 struct net *net;
@@ -1851,8 +1840,7 @@ ip_vs_forward_icmp(const struct nf_hook_ops *ops, struct sk_buff *skb,
1851#ifdef CONFIG_IP_VS_IPV6 1840#ifdef CONFIG_IP_VS_IPV6
1852static unsigned int 1841static unsigned int
1853ip_vs_forward_icmp_v6(const struct nf_hook_ops *ops, struct sk_buff *skb, 1842ip_vs_forward_icmp_v6(const struct nf_hook_ops *ops, struct sk_buff *skb,
1854 const struct net_device *in, const struct net_device *out, 1843 const struct nf_hook_state *state)
1855 int (*okfn)(struct sk_buff *))
1856{ 1844{
1857 int r; 1845 int r;
1858 struct net *net; 1846 struct net *net;
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index edc66de39f2e..7e392edaab97 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4852,21 +4852,17 @@ static unsigned int selinux_ip_forward(struct sk_buff *skb,
4852 4852
4853static unsigned int selinux_ipv4_forward(const struct nf_hook_ops *ops, 4853static unsigned int selinux_ipv4_forward(const struct nf_hook_ops *ops,
4854 struct sk_buff *skb, 4854 struct sk_buff *skb,
4855 const struct net_device *in, 4855 const struct nf_hook_state *state)
4856 const struct net_device *out,
4857 int (*okfn)(struct sk_buff *))
4858{ 4856{
4859 return selinux_ip_forward(skb, in, PF_INET); 4857 return selinux_ip_forward(skb, state->in, PF_INET);
4860} 4858}
4861 4859
4862#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 4860#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
4863static unsigned int selinux_ipv6_forward(const struct nf_hook_ops *ops, 4861static unsigned int selinux_ipv6_forward(const struct nf_hook_ops *ops,
4864 struct sk_buff *skb, 4862 struct sk_buff *skb,
4865 const struct net_device *in, 4863 const struct nf_hook_state *state)
4866 const struct net_device *out,
4867 int (*okfn)(struct sk_buff *))
4868{ 4864{
4869 return selinux_ip_forward(skb, in, PF_INET6); 4865 return selinux_ip_forward(skb, state->in, PF_INET6);
4870} 4866}
4871#endif /* IPV6 */ 4867#endif /* IPV6 */
4872 4868
@@ -4914,9 +4910,7 @@ static unsigned int selinux_ip_output(struct sk_buff *skb,
4914 4910
4915static unsigned int selinux_ipv4_output(const struct nf_hook_ops *ops, 4911static unsigned int selinux_ipv4_output(const struct nf_hook_ops *ops,
4916 struct sk_buff *skb, 4912 struct sk_buff *skb,
4917 const struct net_device *in, 4913 const struct nf_hook_state *state)
4918 const struct net_device *out,
4919 int (*okfn)(struct sk_buff *))
4920{ 4914{
4921 return selinux_ip_output(skb, PF_INET); 4915 return selinux_ip_output(skb, PF_INET);
4922} 4916}
@@ -5091,21 +5085,17 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb,
5091 5085
5092static unsigned int selinux_ipv4_postroute(const struct nf_hook_ops *ops, 5086static unsigned int selinux_ipv4_postroute(const struct nf_hook_ops *ops,
5093 struct sk_buff *skb, 5087 struct sk_buff *skb,
5094 const struct net_device *in, 5088 const struct nf_hook_state *state)
5095 const struct net_device *out,
5096 int (*okfn)(struct sk_buff *))
5097{ 5089{
5098 return selinux_ip_postroute(skb, out, PF_INET); 5090 return selinux_ip_postroute(skb, state->out, PF_INET);
5099} 5091}
5100 5092
5101#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 5093#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
5102static unsigned int selinux_ipv6_postroute(const struct nf_hook_ops *ops, 5094static unsigned int selinux_ipv6_postroute(const struct nf_hook_ops *ops,
5103 struct sk_buff *skb, 5095 struct sk_buff *skb,
5104 const struct net_device *in, 5096 const struct nf_hook_state *state)
5105 const struct net_device *out,
5106 int (*okfn)(struct sk_buff *))
5107{ 5097{
5108 return selinux_ip_postroute(skb, out, PF_INET6); 5098 return selinux_ip_postroute(skb, state->out, PF_INET6);
5109} 5099}
5110#endif /* IPV6 */ 5100#endif /* IPV6 */
5111 5101
diff --git a/security/smack/smack_netfilter.c b/security/smack/smack_netfilter.c
index c952632afb0d..a455cfc9ec1f 100644
--- a/security/smack/smack_netfilter.c
+++ b/security/smack/smack_netfilter.c
@@ -23,9 +23,7 @@
23 23
24static unsigned int smack_ipv6_output(const struct nf_hook_ops *ops, 24static unsigned int smack_ipv6_output(const struct nf_hook_ops *ops,
25 struct sk_buff *skb, 25 struct sk_buff *skb,
26 const struct net_device *in, 26 const struct nf_hook_state *state)
27 const struct net_device *out,
28 int (*okfn)(struct sk_buff *))
29{ 27{
30 struct socket_smack *ssp; 28 struct socket_smack *ssp;
31 struct smack_known *skp; 29 struct smack_known *skp;
@@ -42,9 +40,7 @@ static unsigned int smack_ipv6_output(const struct nf_hook_ops *ops,
42 40
43static unsigned int smack_ipv4_output(const struct nf_hook_ops *ops, 41static unsigned int smack_ipv4_output(const struct nf_hook_ops *ops,
44 struct sk_buff *skb, 42 struct sk_buff *skb,
45 const struct net_device *in, 43 const struct nf_hook_state *state)
46 const struct net_device *out,
47 int (*okfn)(struct sk_buff *))
48{ 44{
49 struct socket_smack *ssp; 45 struct socket_smack *ssp;
50 struct smack_known *skp; 46 struct smack_known *skp;