aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge/br_fdb.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2014-11-28 08:34:15 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-02 23:01:18 -0500
commitf6f6424ba773da6221ecaaa70973eb4dacfa03b2 (patch)
tree76b4c5cea45c1a569d6cbd2f896e07f6b45d523e /net/bridge/br_fdb.c
parent93859b13fa7ecef9d4d8bab4a7acc9f212c8fce2 (diff)
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>
Diffstat (limited to 'net/bridge/br_fdb.c')
-rw-r--r--net/bridge/br_fdb.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 08ef4e7a2439..b1be971eb06c 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -805,33 +805,17 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge_port *p,
805/* Add new permanent fdb entry with RTM_NEWNEIGH */ 805/* Add new permanent fdb entry with RTM_NEWNEIGH */
806int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], 806int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
807 struct net_device *dev, 807 struct net_device *dev,
808 const unsigned char *addr, u16 nlh_flags) 808 const unsigned char *addr, u16 vid, u16 nlh_flags)
809{ 809{
810 struct net_bridge_port *p; 810 struct net_bridge_port *p;
811 int err = 0; 811 int err = 0;
812 struct net_port_vlans *pv; 812 struct net_port_vlans *pv;
813 unsigned short vid = VLAN_N_VID;
814 813
815 if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) { 814 if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE))) {
816 pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n", ndm->ndm_state); 815 pr_info("bridge: RTM_NEWNEIGH with invalid state %#x\n", ndm->ndm_state);
817 return -EINVAL; 816 return -EINVAL;
818 } 817 }
819 818
820 if (tb[NDA_VLAN]) {
821 if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
822 pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
823 return -EINVAL;
824 }
825
826 vid = nla_get_u16(tb[NDA_VLAN]);
827
828 if (!vid || vid >= VLAN_VID_MASK) {
829 pr_info("bridge: RTM_NEWNEIGH with invalid vlan id %d\n",
830 vid);
831 return -EINVAL;
832 }
833 }
834
835 if (is_zero_ether_addr(addr)) { 819 if (is_zero_ether_addr(addr)) {
836 pr_info("bridge: RTM_NEWNEIGH with invalid ether address\n"); 820 pr_info("bridge: RTM_NEWNEIGH with invalid ether address\n");
837 return -EINVAL; 821 return -EINVAL;
@@ -845,7 +829,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
845 } 829 }
846 830
847 pv = nbp_get_vlan_info(p); 831 pv = nbp_get_vlan_info(p);
848 if (vid != VLAN_N_VID) { 832 if (vid) {
849 if (!pv || !test_bit(vid, pv->vlan_bitmap)) { 833 if (!pv || !test_bit(vid, pv->vlan_bitmap)) {
850 pr_info("bridge: RTM_NEWNEIGH with unconfigured " 834 pr_info("bridge: RTM_NEWNEIGH with unconfigured "
851 "vlan %d on port %s\n", vid, dev->name); 835 "vlan %d on port %s\n", vid, dev->name);
@@ -903,27 +887,12 @@ static int __br_fdb_delete(struct net_bridge_port *p,
903/* Remove neighbor entry with RTM_DELNEIGH */ 887/* Remove neighbor entry with RTM_DELNEIGH */
904int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], 888int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
905 struct net_device *dev, 889 struct net_device *dev,
906 const unsigned char *addr) 890 const unsigned char *addr, u16 vid)
907{ 891{
908 struct net_bridge_port *p; 892 struct net_bridge_port *p;
909 int err; 893 int err;
910 struct net_port_vlans *pv; 894 struct net_port_vlans *pv;
911 unsigned short vid = VLAN_N_VID;
912
913 if (tb[NDA_VLAN]) {
914 if (nla_len(tb[NDA_VLAN]) != sizeof(unsigned short)) {
915 pr_info("bridge: RTM_NEWNEIGH with invalid vlan\n");
916 return -EINVAL;
917 }
918 895
919 vid = nla_get_u16(tb[NDA_VLAN]);
920
921 if (!vid || vid >= VLAN_VID_MASK) {
922 pr_info("bridge: RTM_NEWNEIGH with invalid vlan id %d\n",
923 vid);
924 return -EINVAL;
925 }
926 }
927 p = br_port_get_rtnl(dev); 896 p = br_port_get_rtnl(dev);
928 if (p == NULL) { 897 if (p == NULL) {
929 pr_info("bridge: RTM_DELNEIGH %s not a bridge port\n", 898 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[],
932 } 901 }
933 902
934 pv = nbp_get_vlan_info(p); 903 pv = nbp_get_vlan_info(p);
935 if (vid != VLAN_N_VID) { 904 if (vid) {
936 if (!pv || !test_bit(vid, pv->vlan_bitmap)) { 905 if (!pv || !test_bit(vid, pv->vlan_bitmap)) {
937 pr_info("bridge: RTM_DELNEIGH with unconfigured " 906 pr_info("bridge: RTM_DELNEIGH with unconfigured "
938 "vlan %d on port %s\n", vid, dev->name); 907 "vlan %d on port %s\n", vid, dev->name);