net: make vid as a parameter for ndo_fdb_add/ndo_fdb_del
Do the work of parsing NDA_VLAN directly in rtnetlink code, pass simple u16 vid to drivers from there. Signed-off-by: Jiri Pirko <jiri@resnulli.us> Acked-by: Andy Gospodarek <gospo@cumulusnetworks.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Acked-by: John Fastabend <john.r.fastabend@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
93859b13fa
commit
f6f6424ba7
@@ -805,33 +805,17 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge_port *p,
|
||||
/* Add new permanent fdb entry with RTM_NEWNEIGH */
|
||||
int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
struct net_device *dev,
|
||||
const unsigned char *addr, u16 nlh_flags)
|
||||
const unsigned char *addr, u16 vid, u16 nlh_flags)
|
||||
{
|
||||
struct net_bridge_port *p;
|
||||
int err = 0;
|
||||
struct net_port_vlans *pv;
|
||||
unsigned short vid = VLAN_N_VID;
|
||||
|
||||
if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n", ndm->ndm_state);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (tb[NDA_VLAN]) {
|
||||
if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
vid = nla_get_u16(tb[NDA_VLAN]);
|
||||
|
||||
if (!vid || vid >= VLAN_VID_MASK) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with invalid vlan id %d\n",
|
||||
vid);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_zero_ether_addr(addr)) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with invalid ether address\n");
|
||||
return -EINVAL;
|
||||
@@ -845,7 +829,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
pv = nbp_get_vlan_info(p);
|
||||
if (vid != VLAN_N_VID) {
|
||||
if (vid) {
|
||||
if (!pv || !test_bit(vid, pv->vlan_bitmap)) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with unconfigured "
|
||||
"vlan %d on port %s\n", vid, dev->name);
|
||||
@@ -903,27 +887,12 @@ static int __br_fdb_delete(struct net_bridge_port *p,
|
||||
/* Remove neighbor entry with RTM_DELNEIGH */
|
||||
int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
struct net_device *dev,
|
||||
const unsigned char *addr)
|
||||
const unsigned char *addr, u16 vid)
|
||||
{
|
||||
struct net_bridge_port *p;
|
||||
int err;
|
||||
struct net_port_vlans *pv;
|
||||
unsigned short vid = VLAN_N_VID;
|
||||
|
||||
if (tb[NDA_VLAN]) {
|
||||
if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
vid = nla_get_u16(tb[NDA_VLAN]);
|
||||
|
||||
if (!vid || vid >= VLAN_VID_MASK) {
|
||||
pr_info("bridge: RTM_NEWNEIGH with invalid vlan id %d\n",
|
||||
vid);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
p = br_port_get_rtnl(dev);
|
||||
if (p == NULL) {
|
||||
pr_info("bridge: RTM_DELNEIGH %s not a bridge port\n",
|
||||
@@ -932,7 +901,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
}
|
||||
|
||||
pv = nbp_get_vlan_info(p);
|
||||
if (vid != VLAN_N_VID) {
|
||||
if (vid) {
|
||||
if (!pv || !test_bit(vid, pv->vlan_bitmap)) {
|
||||
pr_info("bridge: RTM_DELNEIGH with unconfigured "
|
||||
"vlan %d on port %s\n", vid, dev->name);
|
||||
|
@@ -404,9 +404,9 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
|
||||
const unsigned char *addr, u16 vid, bool added_by_user);
|
||||
|
||||
int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
|
||||
struct net_device *dev, const unsigned char *addr);
|
||||
struct net_device *dev, const unsigned char *addr, u16 vid);
|
||||
int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev,
|
||||
const unsigned char *addr, u16 nlh_flags);
|
||||
const unsigned char *addr, u16 vid, u16 nlh_flags);
|
||||
int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
|
||||
struct net_device *dev, struct net_device *fdev, int idx);
|
||||
int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
|
||||
|
Reference in New Issue
Block a user