netfilter: nf_tables: Use pkt->net instead of computing net from the passed net_devices
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 18 Sep 2015 19:33:01 +0000 (14:33 -0500)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 18 Sep 2015 19:58:49 +0000 (21:58 +0200)
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/netfilter/nft_reject_bridge.c
net/ipv6/netfilter/nft_reject_ipv6.c
net/netfilter/nf_tables_core.c
net/netfilter/nft_log.c
net/netfilter/nft_reject_inet.c

index cee92612b2ccfa1ee1af70cc018b888c08ad7e50..fdba3d9fbff3bac00b8acc68d1eaeda2e492e820 100644 (file)
@@ -261,7 +261,6 @@ static void nft_reject_bridge_eval(const struct nft_expr *expr,
                                   const struct nft_pktinfo *pkt)
 {
        struct nft_reject *priv = nft_expr_priv(expr);
-       struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out);
        const unsigned char *dest = eth_hdr(pkt->skb)->h_dest;
 
        if (is_broadcast_ether_addr(dest) ||
@@ -290,17 +289,17 @@ static void nft_reject_bridge_eval(const struct nft_expr *expr,
        case htons(ETH_P_IPV6):
                switch (priv->type) {
                case NFT_REJECT_ICMP_UNREACH:
-                       nft_reject_br_send_v6_unreach(net, pkt->skb, pkt->in,
-                                                     pkt->hook,
+                       nft_reject_br_send_v6_unreach(pkt->net, pkt->skb,
+                                                     pkt->in, pkt->hook,
                                                      priv->icmp_code);
                        break;
                case NFT_REJECT_TCP_RST:
-                       nft_reject_br_send_v6_tcp_reset(net, pkt->skb, pkt->in,
-                                                       pkt->hook);
+                       nft_reject_br_send_v6_tcp_reset(pkt->net, pkt->skb,
+                                                       pkt->in, pkt->hook);
                        break;
                case NFT_REJECT_ICMPX_UNREACH:
-                       nft_reject_br_send_v6_unreach(net, pkt->skb, pkt->in,
-                                                     pkt->hook,
+                       nft_reject_br_send_v6_unreach(pkt->net, pkt->skb,
+                                                     pkt->in, pkt->hook,
                                                      nft_reject_icmpv6_code(priv->icmp_code));
                        break;
                }
index ffcac7d5da43aa08025b04d69144836e5c67a407..533cd5719c594e7664c162b59037bb43a10c717c 100644 (file)
@@ -24,14 +24,14 @@ static void nft_reject_ipv6_eval(const struct nft_expr *expr,
                                 const struct nft_pktinfo *pkt)
 {
        struct nft_reject *priv = nft_expr_priv(expr);
-       struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out);
 
        switch (priv->type) {
        case NFT_REJECT_ICMP_UNREACH:
-               nf_send_unreach6(net, pkt->skb, priv->icmp_code, pkt->hook);
+               nf_send_unreach6(pkt->net, pkt->skb, priv->icmp_code,
+                                pkt->hook);
                break;
        case NFT_REJECT_TCP_RST:
-               nf_send_reset6(net, pkt->skb, pkt->hook);
+               nf_send_reset6(pkt->net, pkt->skb, pkt->hook);
                break;
        default:
                break;
index 539083099c0d42642c12796d641bf3659f7fa44c..e5c1f332e45e1bc684468fbd97912a8ff96a7853 100644 (file)
@@ -48,9 +48,7 @@ static void __nft_trace_packet(const struct nft_pktinfo *pkt,
                               const struct nft_chain *chain,
                               int rulenum, enum nft_trace type)
 {
-       struct net *net = dev_net(pkt->in ? pkt->in : pkt->out);
-
-       nf_log_trace(net, pkt->pf, pkt->hook, pkt->skb, pkt->in,
+       nf_log_trace(pkt->net, pkt->pf, pkt->hook, pkt->skb, pkt->in,
                     pkt->out, &trace_loginfo, "TRACE: %s:%s:%s:%u ",
                     chain->table->name, chain->name, comments[type],
                     rulenum);
@@ -114,7 +112,7 @@ unsigned int
 nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops)
 {
        const struct nft_chain *chain = ops->priv, *basechain = chain;
-       const struct net *net = dev_net(pkt->in ? pkt->in : pkt->out);
+       const struct net *net = pkt->net;
        const struct nft_rule *rule;
        const struct nft_expr *expr, *last;
        struct nft_regs regs;
index c7c7df85f0b73ff236e0c211aa2ae99cb9b5b88a..319c22b4bca2386c0ba6f95bca3e0aba104660d0 100644 (file)
@@ -31,9 +31,8 @@ static void nft_log_eval(const struct nft_expr *expr,
                         const struct nft_pktinfo *pkt)
 {
        const struct nft_log *priv = nft_expr_priv(expr);
-       struct net *net = dev_net(pkt->in ? pkt->in : pkt->out);
 
-       nf_log_packet(net, pkt->pf, pkt->hook, pkt->skb, pkt->in,
+       nf_log_packet(pkt->net, pkt->pf, pkt->hook, pkt->skb, pkt->in,
                      pkt->out, &priv->loginfo, "%s", priv->prefix);
 }
 
index dea6750af6ffedc809afafa46463b58717a819ae..0bc19f97e23888cc880164ceb9e0588ca148ec59 100644 (file)
@@ -22,7 +22,6 @@ static void nft_reject_inet_eval(const struct nft_expr *expr,
                                 const struct nft_pktinfo *pkt)
 {
        struct nft_reject *priv = nft_expr_priv(expr);
-       struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out);
 
        switch (pkt->pf) {
        case NFPROTO_IPV4:
@@ -44,14 +43,14 @@ static void nft_reject_inet_eval(const struct nft_expr *expr,
        case NFPROTO_IPV6:
                switch (priv->type) {
                case NFT_REJECT_ICMP_UNREACH:
-                       nf_send_unreach6(net, pkt->skb, priv->icmp_code,
+                       nf_send_unreach6(pkt->net, pkt->skb, priv->icmp_code,
                                         pkt->hook);
                        break;
                case NFT_REJECT_TCP_RST:
-                       nf_send_reset6(net, pkt->skb, pkt->hook);
+                       nf_send_reset6(pkt->net, pkt->skb, pkt->hook);
                        break;
                case NFT_REJECT_ICMPX_UNREACH:
-                       nf_send_unreach6(net, pkt->skb,
+                       nf_send_unreach6(pkt->net, pkt->skb,
                                         nft_reject_icmpv6_code(priv->icmp_code),
                                         pkt->hook);
                        break;