net: bridge: convert nf call options to bits

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>
This commit is contained in:
Nikolay Aleksandrov 2018-09-26 17:01:01 +03:00 committed by David S. Miller
parent ae75767ec2
commit 8df3510f28
4 changed files with 19 additions and 18 deletions

View File

@ -487,14 +487,15 @@ static unsigned int br_nf_pre_routing(void *priv,
br = p->br; br = p->br;
if (IS_IPV6(skb) || IS_VLAN_IPV6(skb) || IS_PPPOE_IPV6(skb)) { 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; return NF_ACCEPT;
nf_bridge_pull_encap_header_rcsum(skb); nf_bridge_pull_encap_header_rcsum(skb);
return br_nf_pre_routing_ipv6(priv, skb, state); 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; return NF_ACCEPT;
if (!IS_IP(skb) && !IS_VLAN_IP(skb) && !IS_PPPOE_IP(skb)) 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; return NF_ACCEPT;
br = p->br; 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; return NF_ACCEPT;
if (!IS_ARP(skb)) { if (!IS_ARP(skb)) {

View File

@ -1271,19 +1271,19 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
if (data[IFLA_BR_NF_CALL_IPTABLES]) { if (data[IFLA_BR_NF_CALL_IPTABLES]) {
u8 val = nla_get_u8(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]) { if (data[IFLA_BR_NF_CALL_IP6TABLES]) {
u8 val = nla_get_u8(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]) { if (data[IFLA_BR_NF_CALL_ARPTABLES]) {
u8 val = nla_get_u8(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 #endif
@ -1470,11 +1470,11 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
#endif #endif
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
if (nla_put_u8(skb, IFLA_BR_NF_CALL_IPTABLES, 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, 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, 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; return -EMSGSIZE;
#endif #endif

View File

@ -309,6 +309,9 @@ static inline struct net_bridge_port *br_port_get_rtnl_rcu(const struct net_devi
enum net_bridge_opts { enum net_bridge_opts {
BROPT_VLAN_ENABLED, BROPT_VLAN_ENABLED,
BROPT_VLAN_STATS_ENABLED, BROPT_VLAN_STATS_ENABLED,
BROPT_NF_CALL_IPTABLES,
BROPT_NF_CALL_IP6TABLES,
BROPT_NF_CALL_ARPTABLES,
}; };
struct net_bridge { struct net_bridge {
@ -331,9 +334,6 @@ struct net_bridge {
struct rtable fake_rtable; struct rtable fake_rtable;
struct rt6_info fake_rt6_info; struct rt6_info fake_rt6_info;
}; };
bool nf_call_iptables;
bool nf_call_ip6tables;
bool nf_call_arptables;
#endif #endif
u16 group_fwd_mask; u16 group_fwd_mask;
u16 group_fwd_mask_required; u16 group_fwd_mask_required;

View File

@ -678,12 +678,12 @@ static ssize_t nf_call_iptables_show(
struct device *d, struct device_attribute *attr, char *buf) struct device *d, struct device_attribute *attr, char *buf)
{ {
struct net_bridge *br = to_bridge(d); 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) 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; return 0;
} }
@ -699,12 +699,12 @@ static ssize_t nf_call_ip6tables_show(
struct device *d, struct device_attribute *attr, char *buf) struct device *d, struct device_attribute *attr, char *buf)
{ {
struct net_bridge *br = to_bridge(d); 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) 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; return 0;
} }
@ -720,12 +720,12 @@ static ssize_t nf_call_arptables_show(
struct device *d, struct device_attribute *attr, char *buf) struct device *d, struct device_attribute *attr, char *buf)
{ {
struct net_bridge *br = to_bridge(d); 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) 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; return 0;
} }