History

bridge: vlan: Allow setting VLAN neighbor suppression state

Add a new VLAN attribute that allows user space to set the neighbor suppression state of the port VLAN. Example: # bridge -d -j -p vlan show dev swp1 vid 10 | jq '.[]["vlans"][]["neigh_suppress"]' false # bridge vlan set vid 10 dev swp1 neigh_suppress on # bridge -d -j -p vlan show dev swp1 vid 10 | jq '.[]["vlans"][]["neigh_suppress"]' true # bridge vlan set vid 10 dev swp1 neigh_suppress off # bridge -d -j -p vlan show dev swp1 vid 10 | jq '.[]["vlans"][]["neigh_suppress"]' false # bridge vlan set vid 10 dev br0 neigh_suppress on Error: bridge: Can't set neigh_suppress for non-port vlans.

Ido Schimmel committed 3 years ago

Commit 83f6d601 parent 412614b3 files · +21 −1Browse files

Unified · Split

3 files
  1. include/uapi/linux/if_bridge.h +1 −0
  2. net/bridge/br_vlan.c +1 −0
  3. net/bridge/br_vlan_options.c +19 −1
include/uapi/linux/if_bridge.h+1−0
@@ -525,6 +525,7 @@ enum { · 524 unmodified lines
525 BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,525 BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
526 BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS,526 BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS,
527 BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS,527 BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS,
528 BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS,
528 __BRIDGE_VLANDB_ENTRY_MAX,529 __BRIDGE_VLANDB_ENTRY_MAX,
529};530};
530#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)531#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
net/bridge/br_vlan.c+1−0
@@ -2134,6 +2134,7 @@ static const struct nla_policy br_vlan_db_policy[BRIDGE_VLANDB_ENTRY_MAX + 1] = · 2133 unmodified lines
2134 [BRIDGE_VLANDB_ENTRY_MCAST_ROUTER] = { .type = NLA_U8 },2134 [BRIDGE_VLANDB_ENTRY_MCAST_ROUTER] = { .type = NLA_U8 },
2135 [BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS] = { .type = NLA_REJECT },2135 [BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS] = { .type = NLA_REJECT },
2136 [BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS] = { .type = NLA_U32 },2136 [BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS] = { .type = NLA_U32 },
2137 [BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS] = NLA_POLICY_MAX(NLA_U8, 1),
2137};2138};
2138 2139
2139static int br_vlan_rtm_process_one(struct net_device *dev,2140static int br_vlan_rtm_process_one(struct net_device *dev,
net/bridge/br_vlan_options.c+19−1
@@ -52,7 +52,9 @@ bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v, · 51 unmodified lines
52 const struct net_bridge_port *p)52 const struct net_bridge_port *p)
53{53{
54 if (nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_STATE, br_vlan_get_state(v)) ||54 if (nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_STATE, br_vlan_get_state(v)) ||
55 !__vlan_tun_put(skb, v))55 !__vlan_tun_put(skb, v) ||
56 nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS,
57 !!(v->priv_flags & BR_VLFLAG_NEIGH_SUPPRESS_ENABLED)))
56 return false;58 return false;
57 59
58#ifdef CONFIG_BRIDGE_IGMP_SNOOPING60#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
@@ -80,6 +82,7 @@ size_t br_vlan_opts_nl_size(void) · 21 unmodified lines
80 + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS */82 + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS */
81 + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS */83 + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS */
82#endif84#endif
85 + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS */
83 + 0;86 + 0;
84}87}
85 88
@@ -239,6 +242,21 @@ static int br_vlan_process_one_opts(const struct net_bridge *br, · 153 unmodified lines
239 }242 }
240#endif243#endif
241 244
245 if (tb[BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS]) {
246 bool enabled = v->priv_flags & BR_VLFLAG_NEIGH_SUPPRESS_ENABLED;
247 bool val = nla_get_u8(tb[BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS]);
248
249 if (!p) {
250 NL_SET_ERR_MSG_MOD(extack, "Can't set neigh_suppress for non-port vlans");
251 return -EINVAL;
252 }
253
254 if (val != enabled) {
255 v->priv_flags ^= BR_VLFLAG_NEIGH_SUPPRESS_ENABLED;
256 *changed = true;
257 }
258 }
259
242 return 0;260 return 0;
243}261}
244 262

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t