]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: bridge: convert nf call options to bits
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Wed, 26 Sep 2018 14:01:01 +0000 (17:01 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Sep 2018 17:04:23 +0000 (10:04 -0700)
No functional change, convert of nf_call_[ip|ip6|arp]tables to bits.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_netfilter_hooks.c
net/bridge/br_netlink.c
net/bridge/br_private.h
net/bridge/br_sysfs_br.c

index 6e0dc6bcd32af7e056e3006fdc0a483aaf4771d1..e0a3b038d05228544ec46624b466ee3f72c21196 100644 (file)
@@ -487,14 +487,15 @@ static unsigned int br_nf_pre_routing(void *priv,
        br = p->br;
 
        if (IS_IPV6(skb) || IS_VLAN_IPV6(skb) || IS_PPPOE_IPV6(skb)) {
-               if (!brnf_call_ip6tables && !br->nf_call_ip6tables)
+               if (!brnf_call_ip6tables &&
+                   !br_opt_get(br, BROPT_NF_CALL_IP6TABLES))
                        return NF_ACCEPT;
 
                nf_bridge_pull_encap_header_rcsum(skb);
                return br_nf_pre_routing_ipv6(priv, skb, state);
        }
 
-       if (!brnf_call_iptables && !br->nf_call_iptables)
+       if (!brnf_call_iptables && !br_opt_get(br, BROPT_NF_CALL_IPTABLES))
                return NF_ACCEPT;
 
        if (!IS_IP(skb) && !IS_VLAN_IP(skb) && !IS_PPPOE_IP(skb))
@@ -636,7 +637,7 @@ static unsigned int br_nf_forward_arp(void *priv,
                return NF_ACCEPT;
        br = p->br;
 
-       if (!brnf_call_arptables && !br->nf_call_arptables)
+       if (!brnf_call_arptables && !br_opt_get(br, BROPT_NF_CALL_ARPTABLES))
                return NF_ACCEPT;
 
        if (!IS_ARP(skb)) {
index 6a53caff2d317d49963dd4e636db0b1bc394d91c..521893df0c2a6618ae15633b34c8d64beeee7f33 100644 (file)
@@ -1271,19 +1271,19 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
        if (data[IFLA_BR_NF_CALL_IPTABLES]) {
                u8 val = nla_get_u8(data[IFLA_BR_NF_CALL_IPTABLES]);
 
-               br->nf_call_iptables = val ? true : false;
+               br_opt_toggle(br, BROPT_NF_CALL_IPTABLES, !!val);
        }
 
        if (data[IFLA_BR_NF_CALL_IP6TABLES]) {
                u8 val = nla_get_u8(data[IFLA_BR_NF_CALL_IP6TABLES]);
 
-               br->nf_call_ip6tables = val ? true : false;
+               br_opt_toggle(br, BROPT_NF_CALL_IP6TABLES, !!val);
        }
 
        if (data[IFLA_BR_NF_CALL_ARPTABLES]) {
                u8 val = nla_get_u8(data[IFLA_BR_NF_CALL_ARPTABLES]);
 
-               br->nf_call_arptables = val ? true : false;
+               br_opt_toggle(br, BROPT_NF_CALL_ARPTABLES, !!val);
        }
 #endif
 
@@ -1470,11 +1470,11 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
 #endif
 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
        if (nla_put_u8(skb, IFLA_BR_NF_CALL_IPTABLES,
-                      br->nf_call_iptables ? 1 : 0) ||
+                      br_opt_get(br, BROPT_NF_CALL_IPTABLES) ? 1 : 0) ||
            nla_put_u8(skb, IFLA_BR_NF_CALL_IP6TABLES,
-                      br->nf_call_ip6tables ? 1 : 0) ||
+                      br_opt_get(br, BROPT_NF_CALL_IP6TABLES) ? 1 : 0) ||
            nla_put_u8(skb, IFLA_BR_NF_CALL_ARPTABLES,
-                      br->nf_call_arptables ? 1 : 0))
+                      br_opt_get(br, BROPT_NF_CALL_ARPTABLES) ? 1 : 0))
                return -EMSGSIZE;
 #endif
 
index 0abb632283ff5ef341a00a9564ccb0324777313e..d8eadab09d7d19a5e6d376f0e12bc18fd86efc22 100644 (file)
@@ -309,6 +309,9 @@ static inline struct net_bridge_port *br_port_get_rtnl_rcu(const struct net_devi
 enum net_bridge_opts {
        BROPT_VLAN_ENABLED,
        BROPT_VLAN_STATS_ENABLED,
+       BROPT_NF_CALL_IPTABLES,
+       BROPT_NF_CALL_IP6TABLES,
+       BROPT_NF_CALL_ARPTABLES,
 };
 
 struct net_bridge {
@@ -331,9 +334,6 @@ struct net_bridge {
                struct rtable           fake_rtable;
                struct rt6_info         fake_rt6_info;
        };
-       bool                            nf_call_iptables;
-       bool                            nf_call_ip6tables;
-       bool                            nf_call_arptables;
 #endif
        u16                             group_fwd_mask;
        u16                             group_fwd_mask_required;
index 9f1f3866c83341fce8d9cd3b0930c601a198e0ab..0f8545c94948da24de96a8d5da00b4a16484b15e 100644 (file)
@@ -678,12 +678,12 @@ static ssize_t nf_call_iptables_show(
        struct device *d, struct device_attribute *attr, char *buf)
 {
        struct net_bridge *br = to_bridge(d);
-       return sprintf(buf, "%u\n", br->nf_call_iptables);
+       return sprintf(buf, "%u\n", br_opt_get(br, BROPT_NF_CALL_IPTABLES));
 }
 
 static int set_nf_call_iptables(struct net_bridge *br, unsigned long val)
 {
-       br->nf_call_iptables = val ? true : false;
+       br_opt_toggle(br, BROPT_NF_CALL_IPTABLES, !!val);
        return 0;
 }
 
@@ -699,12 +699,12 @@ static ssize_t nf_call_ip6tables_show(
        struct device *d, struct device_attribute *attr, char *buf)
 {
        struct net_bridge *br = to_bridge(d);
-       return sprintf(buf, "%u\n", br->nf_call_ip6tables);
+       return sprintf(buf, "%u\n", br_opt_get(br, BROPT_NF_CALL_IP6TABLES));
 }
 
 static int set_nf_call_ip6tables(struct net_bridge *br, unsigned long val)
 {
-       br->nf_call_ip6tables = val ? true : false;
+       br_opt_toggle(br, BROPT_NF_CALL_IP6TABLES, !!val);
        return 0;
 }
 
@@ -720,12 +720,12 @@ static ssize_t nf_call_arptables_show(
        struct device *d, struct device_attribute *attr, char *buf)
 {
        struct net_bridge *br = to_bridge(d);
-       return sprintf(buf, "%u\n", br->nf_call_arptables);
+       return sprintf(buf, "%u\n", br_opt_get(br, BROPT_NF_CALL_ARPTABLES));
 }
 
 static int set_nf_call_arptables(struct net_bridge *br, unsigned long val)
 {
-       br->nf_call_arptables = val ? true : false;
+       br_opt_toggle(br, BROPT_NF_CALL_ARPTABLES, !!val);
        return 0;
 }