diff options
author | Vlad Yasevich <vyasevich@gmail.com> | 2014-10-03 11:29:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-05 21:21:36 -0400 |
commit | 3df6bf45ec008942f16f1814123c4bdebcf50741 (patch) | |
tree | b32c86020856bb9ad6065d28c2bff015efeb54c0 | |
parent | 96a20d9d7fff7068a2233b00379f0778a150bf86 (diff) |
bridge: Simplify pvid checks.
Currently, if the pvid is not set, we return an illegal vlan value
even though the pvid value is set to 0. Since pvid of 0 is currently
invalid, just return 0 instead. This makes the current and future
checks simpler.
Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/bridge/br_private.h | 7 | ||||
-rw-r--r-- | net/bridge/br_vlan.c | 4 |
2 files changed, 4 insertions, 7 deletions
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 5a347eb1d139..f671561b3053 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -643,11 +643,8 @@ static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid) | |||
643 | 643 | ||
644 | static inline u16 br_get_pvid(const struct net_port_vlans *v) | 644 | static inline u16 br_get_pvid(const struct net_port_vlans *v) |
645 | { | 645 | { |
646 | /* Return just the VID if it is set, or VLAN_N_VID (invalid vid) if | ||
647 | * vid wasn't set | ||
648 | */ | ||
649 | smp_rmb(); | 646 | smp_rmb(); |
650 | return v->pvid ?: VLAN_N_VID; | 647 | return v->pvid; |
651 | } | 648 | } |
652 | 649 | ||
653 | static inline int br_vlan_enabled(struct net_bridge *br) | 650 | static inline int br_vlan_enabled(struct net_bridge *br) |
@@ -746,7 +743,7 @@ static inline u16 br_vlan_get_tag(const struct sk_buff *skb, u16 *tag) | |||
746 | } | 743 | } |
747 | static inline u16 br_get_pvid(const struct net_port_vlans *v) | 744 | static inline u16 br_get_pvid(const struct net_port_vlans *v) |
748 | { | 745 | { |
749 | return VLAN_N_VID; /* Returns invalid vid */ | 746 | return 0; |
750 | } | 747 | } |
751 | 748 | ||
752 | static inline int br_vlan_enabled(struct net_bridge *br) | 749 | static inline int br_vlan_enabled(struct net_bridge *br) |
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index dfa7c9a7e193..e11c9932e706 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c | |||
@@ -223,7 +223,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, | |||
223 | * See if pvid is set on this port. That tells us which | 223 | * See if pvid is set on this port. That tells us which |
224 | * vlan untagged or priority-tagged traffic belongs to. | 224 | * vlan untagged or priority-tagged traffic belongs to. |
225 | */ | 225 | */ |
226 | if (pvid == VLAN_N_VID) | 226 | if (!pvid) |
227 | goto drop; | 227 | goto drop; |
228 | 228 | ||
229 | /* PVID is set on this port. Any untagged or priority-tagged | 229 | /* PVID is set on this port. Any untagged or priority-tagged |
@@ -292,7 +292,7 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid) | |||
292 | 292 | ||
293 | if (!*vid) { | 293 | if (!*vid) { |
294 | *vid = br_get_pvid(v); | 294 | *vid = br_get_pvid(v); |
295 | if (*vid == VLAN_N_VID) | 295 | if (!*vid) |
296 | return false; | 296 | return false; |
297 | 297 | ||
298 | return true; | 298 | return true; |