提交 3df6bf45 编写于 作者: V Vlad Yasevich 提交者: David S. Miller

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: NVladislav Yasevich <vyasevic@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 96a20d9d
...@@ -643,11 +643,8 @@ static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid) ...@@ -643,11 +643,8 @@ static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid)
static inline u16 br_get_pvid(const struct net_port_vlans *v) static inline u16 br_get_pvid(const struct net_port_vlans *v)
{ {
/* Return just the VID if it is set, or VLAN_N_VID (invalid vid) if
* vid wasn't set
*/
smp_rmb(); smp_rmb();
return v->pvid ?: VLAN_N_VID; return v->pvid;
} }
static inline int br_vlan_enabled(struct net_bridge *br) 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,7 +743,7 @@ static inline u16 br_vlan_get_tag(const struct sk_buff *skb, u16 *tag)
} }
static inline u16 br_get_pvid(const struct net_port_vlans *v) static inline u16 br_get_pvid(const struct net_port_vlans *v)
{ {
return VLAN_N_VID; /* Returns invalid vid */ return 0;
} }
static inline int br_vlan_enabled(struct net_bridge *br) static inline int br_vlan_enabled(struct net_bridge *br)
......
...@@ -223,7 +223,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, ...@@ -223,7 +223,7 @@ bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
* See if pvid is set on this port. That tells us which * See if pvid is set on this port. That tells us which
* vlan untagged or priority-tagged traffic belongs to. * vlan untagged or priority-tagged traffic belongs to.
*/ */
if (pvid == VLAN_N_VID) if (!pvid)
goto drop; goto drop;
/* PVID is set on this port. Any untagged or priority-tagged /* 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,7 +292,7 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
if (!*vid) { if (!*vid) {
*vid = br_get_pvid(v); *vid = br_get_pvid(v);
if (*vid == VLAN_N_VID) if (!*vid)
return false; return false;
return true; return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册