forked from Minki/linux
net: bridge: notify on vlan tunnel changes done via the old api
If someone uses the old vlan API to configure tunnel mappings we'll only generate the old-style full port notification. That would be a problem if we are monitoring the new vlan notifications for changes. The patch resolves the issue by adding vlan notifications to the old tunnel netlink code. As usual we try to compress the notifications for as many vlans in a range as possible, thus a vlan tunnel change is considered able to enter the "current" vlan notification range if: 1. vlan exists 2. it has actually changed (curr_change == true) 3. it passes all standard vlan notification range checks done by br_vlan_can_enter_range() such as option equality, id continuity etc Note that vlan tunnel changes (add/del) are considered a part of vlan options so only RTM_NEWVLAN notification is generated with the relevant information inside. Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
71930d6102
commit
9433944368
@ -250,6 +250,36 @@ int br_parse_vlan_tunnel_info(struct nlattr *attr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* send a notification if v_curr can't enter the range and start a new one */
|
||||||
|
static void __vlan_tunnel_handle_range(const struct net_bridge_port *p,
|
||||||
|
struct net_bridge_vlan **v_start,
|
||||||
|
struct net_bridge_vlan **v_end,
|
||||||
|
int v_curr, bool curr_change)
|
||||||
|
{
|
||||||
|
struct net_bridge_vlan_group *vg;
|
||||||
|
struct net_bridge_vlan *v;
|
||||||
|
|
||||||
|
vg = nbp_vlan_group(p);
|
||||||
|
if (!vg)
|
||||||
|
return;
|
||||||
|
|
||||||
|
v = br_vlan_find(vg, v_curr);
|
||||||
|
|
||||||
|
if (!*v_start)
|
||||||
|
goto out_init;
|
||||||
|
|
||||||
|
if (v && curr_change && br_vlan_can_enter_range(v, *v_end)) {
|
||||||
|
*v_end = v;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
br_vlan_notify(p->br, p, (*v_start)->vid, (*v_end)->vid, RTM_NEWVLAN);
|
||||||
|
out_init:
|
||||||
|
/* we start a range only if there are any changes to notify about */
|
||||||
|
*v_start = curr_change ? v : NULL;
|
||||||
|
*v_end = *v_start;
|
||||||
|
}
|
||||||
|
|
||||||
int br_process_vlan_tunnel_info(const struct net_bridge *br,
|
int br_process_vlan_tunnel_info(const struct net_bridge *br,
|
||||||
const struct net_bridge_port *p, int cmd,
|
const struct net_bridge_port *p, int cmd,
|
||||||
struct vtunnel_info *tinfo_curr,
|
struct vtunnel_info *tinfo_curr,
|
||||||
@ -263,6 +293,7 @@ int br_process_vlan_tunnel_info(const struct net_bridge *br,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
memcpy(tinfo_last, tinfo_curr, sizeof(struct vtunnel_info));
|
memcpy(tinfo_last, tinfo_curr, sizeof(struct vtunnel_info));
|
||||||
} else if (tinfo_curr->flags & BRIDGE_VLAN_INFO_RANGE_END) {
|
} else if (tinfo_curr->flags & BRIDGE_VLAN_INFO_RANGE_END) {
|
||||||
|
struct net_bridge_vlan *v_start = NULL, *v_end = NULL;
|
||||||
int t, v;
|
int t, v;
|
||||||
|
|
||||||
if (!(tinfo_last->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN))
|
if (!(tinfo_last->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN))
|
||||||
@ -272,11 +303,24 @@ int br_process_vlan_tunnel_info(const struct net_bridge *br,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
t = tinfo_last->tunid;
|
t = tinfo_last->tunid;
|
||||||
for (v = tinfo_last->vid; v <= tinfo_curr->vid; v++) {
|
for (v = tinfo_last->vid; v <= tinfo_curr->vid; v++) {
|
||||||
err = br_vlan_tunnel_info(p, cmd, v, t, changed);
|
bool curr_change = false;
|
||||||
|
|
||||||
|
err = br_vlan_tunnel_info(p, cmd, v, t, &curr_change);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
break;
|
||||||
t++;
|
t++;
|
||||||
|
|
||||||
|
if (curr_change)
|
||||||
|
*changed = curr_change;
|
||||||
|
__vlan_tunnel_handle_range(p, &v_start, &v_end, v,
|
||||||
|
curr_change);
|
||||||
}
|
}
|
||||||
|
if (v_start && v_end)
|
||||||
|
br_vlan_notify(br, p, v_start->vid, v_end->vid,
|
||||||
|
RTM_NEWVLAN);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
memset(tinfo_last, 0, sizeof(struct vtunnel_info));
|
memset(tinfo_last, 0, sizeof(struct vtunnel_info));
|
||||||
memset(tinfo_curr, 0, sizeof(struct vtunnel_info));
|
memset(tinfo_curr, 0, sizeof(struct vtunnel_info));
|
||||||
} else {
|
} else {
|
||||||
@ -286,6 +330,7 @@ int br_process_vlan_tunnel_info(const struct net_bridge *br,
|
|||||||
tinfo_curr->tunid, changed);
|
tinfo_curr->tunid, changed);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
br_vlan_notify(br, p, tinfo_curr->vid, 0, RTM_NEWVLAN);
|
||||||
memset(tinfo_last, 0, sizeof(struct vtunnel_info));
|
memset(tinfo_last, 0, sizeof(struct vtunnel_info));
|
||||||
memset(tinfo_curr, 0, sizeof(struct vtunnel_info));
|
memset(tinfo_curr, 0, sizeof(struct vtunnel_info));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user