Skip to contentSkip to conversation

rocker: remove swdev mode

PATCH Superseded [email protected] 4 participants 6 messages Dec 7, 2014 – Dec 8, 2014

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 rocker: remove swdev mode

From: Roopa Prabhu <[email protected]>

---
 drivers/net/ethernet/rocker/rocker.c |   18 +-----------------
 include/linux/rtnetlink.h            |    2 +-
 net/core/rtnetlink.c                 |   12 +++++++++---
 3 files changed, 11 insertions(+), 21 deletions(-)
drivers/net/ethernet/rocker/rocker.c +1 -17
index fded127..9f1d256 100644
@@ -3700,27 +3700,11 @@ static int rocker_port_bridge_setlink(struct net_device *dev,
 {
 	struct rocker_port *rocker_port = netdev_priv(dev);
 	struct nlattr *protinfo;
-	struct nlattr *afspec;
 	struct nlattr *attr;
-	u16 mode;
 	int err;
 
 	protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg),
 				   IFLA_PROTINFO);
-	afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
-
-	if (afspec) {
-		attr = nla_find_nested(afspec, IFLA_BRIDGE_MODE);
-		if (attr) {
-			if (nla_len(attr) < sizeof(mode))
-				return -EINVAL;
-
-			mode = nla_get_u16(attr);
-			if (mode != BRIDGE_MODE_SWDEV)
-				return -EINVAL;
-		}
-	}
-
 	if (protinfo) {
 		attr = nla_find_nested(protinfo, IFLA_BRPORT_LEARNING);
 		if (attr) {
@@ -3755,7 +3739,7 @@ static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				      u32 filter_mask)
 {
 	struct rocker_port *rocker_port = netdev_priv(dev);
-	u16 mode = BRIDGE_MODE_SWDEV;
+	u16 mode = -1;
 	u32 mask = BR_LEARNING | BR_LEARNING_SYNC;
 
 	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode,
include/linux/rtnetlink.h +1 -1
index 3b04190..dcfa06b 100644
@@ -103,6 +103,6 @@ extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
 			    u16 vid);
 
 extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
-				   struct net_device *dev, u16 mode,
+				   struct net_device *dev, s16 mode,
 				   u32 flags, u32 mask);
 #endif	/* __LINUX_RTNETLINK_H */
net/core/rtnetlink.c +9 -3
index 61cb7e7..b4e04b9 100644
@@ -2696,7 +2696,7 @@ static int brport_nla_put_flag(struct sk_buff *skb, u32 flags, u32 mask,
 }
 
 int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
-			    struct net_device *dev, u16 mode,
+			    struct net_device *dev, s16 mode,
 			    u32 flags, u32 mask)
 {
 	struct nlmsghdr *nlh;
@@ -2734,11 +2734,17 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 	if (!br_afspec)
 		goto nla_put_failure;
 
-	if (nla_put_u16(skb, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF) ||
-	    nla_put_u16(skb, IFLA_BRIDGE_MODE, mode)) {
+	if (nla_put_u16(skb, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF)) {
 		nla_nest_cancel(skb, br_afspec);
 		goto nla_put_failure;
 	}
+
+	if (mode >= 0) {
+		if (nla_put_u16(skb, IFLA_BRIDGE_MODE, mode)) {
+			nla_nest_cancel(skb, br_afspec);
+			goto nla_put_failure;
+		}
+	}
 	nla_nest_end(skb, br_afspec);
 
 	protinfo = nla_nest_start(skb, IFLA_PROTINFO | NLA_F_NESTED);
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 14 lines · On 12/06/14 at 10:54pm, [email protected] wrote:

From: Roopa Prabhu <[email protected]>

---
 drivers/net/ethernet/rocker/rocker.c |   18 +-----------------
 include/linux/rtnetlink.h            |    2 +-
 net/core/rtnetlink.c                 |   12 +++++++++---
 3 files changed, 11 insertions(+), 21 deletions(-)
drivers/net/ethernet/rocker/rocker.c +0 -0
index fded127..9f1d256 100644

drivers/net/ethernet/rocker/rocker.c static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, · line 3742

Quoted 5 lines
drivers/net/ethernet/rocker/rocker.c +1 -1
@@ -3755,7 +3739,7 @@ static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				      u32 filter_mask)
 {
 	struct rocker_port *rocker_port = netdev_priv(dev);
-	u16 mode = BRIDGE_MODE_SWDEV;
+	u16 mode = -1;
        ^^^

I assume you meant s16

#2 lore raw
Quoted 22 lines · Thomas Graf
Quoted 14 lines · On 12/06/14 at 10:54pm, [email protected] wrote:

From: Roopa Prabhu <[email protected]>

---
  drivers/net/ethernet/rocker/rocker.c |   18 +-----------------
  include/linux/rtnetlink.h            |    2 +-
  net/core/rtnetlink.c                 |   12 +++++++++---
  3 files changed, 11 insertions(+), 21 deletions(-)
drivers/net/ethernet/rocker/rocker.c +0 -0
index fded127..9f1d256 100644

drivers/net/ethernet/rocker/rocker.c static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, · line 3742

Quoted 5 lines
drivers/net/ethernet/rocker/rocker.c +1 -1
@@ -3755,7 +3739,7 @@ static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
  				      u32 filter_mask)
  {
  	struct rocker_port *rocker_port = netdev_priv(dev);
-	u16 mode = BRIDGE_MODE_SWDEV;
+	u16 mode = -1;
         ^^^
Quoted 2 lines

I assume you meant s16

yes :(...i thought i had covered all places....missed this one...resubmitting ..

maintainer
#3 lore raw
In reply to Thomas Graf
Quoted 22 lines · Sun, Dec 07, 2014 at 09:19:28AM CET, [email protected] wrote:
Quoted 14 lines · On 12/06/14 at 10:54pm, [email protected] wrote:

From: Roopa Prabhu <[email protected]>

---
 drivers/net/ethernet/rocker/rocker.c |   18 +-----------------
 include/linux/rtnetlink.h            |    2 +-
 net/core/rtnetlink.c                 |   12 +++++++++---
 3 files changed, 11 insertions(+), 21 deletions(-)
drivers/net/ethernet/rocker/rocker.c +0 -0
index fded127..9f1d256 100644

drivers/net/ethernet/rocker/rocker.c static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, · line 3742

Quoted 5 lines
drivers/net/ethernet/rocker/rocker.c +1 -1
@@ -3755,7 +3739,7 @@ static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 				      u32 filter_mask)
 {
 	struct rocker_port *rocker_port = netdev_priv(dev);
-	u16 mode = BRIDGE_MODE_SWDEV;
+	u16 mode = -1;
       ^^^
Quoted 1 line

I assume you meant s16

well, I see no problem in using u16. IFLA_BRIDGE_MODE attr is u16 so mode should stay u16.

But maybe better to add:
#define BRIDGE_MODE_UNDEF 0xFFFF

?

Quoted 1 line
#4 lore raw
Quoted 4 lines · Jiri Pirko
Quoted 3 lines · Sun, Dec 07, 2014 at 09:19:28AM CET, [email protected] wrote:
Quoted 2 lines · On 12/06/14 at 10:54pm, [email protected] wrote:

From: Roopa Prabhu <[email protected]>

Please provide a normal, non-empty commit message as everyone else ...

Quoted 1 line
Quoted 1 line
Quoted 1 line

...

Quoted 13 lines
Quoted 11 lines

drivers/net/ethernet/rocker/rocker.c static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, · line 3742

Quoted 10 lines
drivers/net/ethernet/rocker/rocker.c +1 -1
index fded127..9f1d256 100644
@@ -3755,7 +3739,7 @@ static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
  				      u32 filter_mask)
  {
  	struct rocker_port *rocker_port = netdev_priv(dev);
-	u16 mode = BRIDGE_MODE_SWDEV;
+	u16 mode = -1;
        ^^^
Quoted 1 line

I assume you meant s16

Quoted 5 lines

well, I see no problem in using u16. IFLA_BRIDGE_MODE attr is u16 so mode should stay u16.

But maybe better to add:
#define BRIDGE_MODE_UNDEF 0xFFFF

Yep, something along these lines seems better.

#5 lore raw
Quoted 8 lines · Daniel Borkmann
Quoted 5 lines · Jiri Pirko

well, I see no problem in using u16. IFLA_BRIDGE_MODE attr is u16 so mode should stay u16.

But maybe better to add:
#define BRIDGE_MODE_UNDEF 0xFFFF

Yep, something along these lines seems better.

Using u16 is fine but then all occurences should use it as opposed to mixed s16/u16 usage as in v3.