netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iproute2: bridge: fix 'bridge link' setlink/getlink parsing
@ 2013-05-29 16:20 John Fastabend
  2013-06-04  2:57 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: John Fastabend @ 2013-05-29 16:20 UTC (permalink / raw)
  To: stephen; +Cc: vyasevic, netdev, bridge

Use IFLA_AF_SPEC nested attributes to lookup bridge mode and when
doing strcmp() check for equality.

These appear to be typos from the original commit,

commit 64108901b737b95247b53dec8c1b8217ca8505b7
Author: Vlad Yasevich <vyasevic@redhat.com>
Date:   Fri Mar 15 10:01:28 2013 -0700

    bridge: Add support for setting bridge port attributes

Also set flags to BRIDGE_FLAGS_SELF instead of using OR operation.
This allows setting the bridge mode when not being used with a
master device.

To allow setting both master and self devices simultaneously we
will need to add a {self|master} field similar to fdb commands.
For now the command sets are mutually exclusive as noted in the
original commit.

With this patch 'bridge link set' works now,

# ./bridge/bridge link set dev veth1 cost 3
# ./bridge/bridge link show
10: veth1 state UP : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state forwarding priority 3 cost 3

CC: Vlad Yasevich <vyasevic@redhat.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
 bridge/link.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/bridge/link.c b/bridge/link.c
index 3188b85..38dfaea 100644
--- a/bridge/link.c
+++ b/bridge/link.c
@@ -198,8 +198,8 @@ int print_linkinfo(const struct sockaddr_nl *who,
 
 		parse_rtattr_nested(aftb, IFLA_BRIDGE_MAX, tb[IFLA_AF_SPEC]);
 
-		if (tb[IFLA_BRIDGE_MODE])
-			print_hwmode(fp, rta_getattr_u16(tb[IFLA_BRIDGE_MODE]));
+		if (aftb[IFLA_BRIDGE_MODE])
+			print_hwmode(fp, rta_getattr_u16(aftb[IFLA_BRIDGE_MODE]));
 	}
 
 	fprintf(fp, "\n");
@@ -281,18 +281,18 @@ static int brlink_modify(int argc, char **argv)
 			NEXT_ARG();
 			if (!on_off("root_block", &root_block, *argv))
 				exit(-1);
-		} else if (strcmp(*argv, "cost")) {
+		} else if (strcmp(*argv, "cost") == 0) {
 			NEXT_ARG();
 			cost = atoi(*argv);
-		} else if (strcmp(*argv, "priority")) {
+		} else if (strcmp(*argv, "priority") == 0) {
 			NEXT_ARG();
 			priority = atoi(*argv);
-		} else if (strcmp(*argv, "state")) {
+		} else if (strcmp(*argv, "state") == 0) {
 			NEXT_ARG();
 			state = atoi(*argv);
-		} else if (strcmp(*argv, "hwmode")) {
+		} else if (strcmp(*argv, "hwmode") == 0) {
 			NEXT_ARG();
-			flags |= BRIDGE_FLAGS_SELF;
+			flags = BRIDGE_FLAGS_SELF;
 			if (strcmp(*argv, "vepa") == 0)
 				mode = BRIDGE_MODE_VEPA;
 			else if (strcmp(*argv, "veb") == 0)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iproute2: bridge: fix 'bridge link' setlink/getlink parsing
  2013-05-29 16:20 [PATCH] iproute2: bridge: fix 'bridge link' setlink/getlink parsing John Fastabend
@ 2013-06-04  2:57 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2013-06-04  2:57 UTC (permalink / raw)
  To: John Fastabend; +Cc: vyasevic, netdev, bridge

On Wed, 29 May 2013 09:20:53 -0700
John Fastabend <john.fastabend@gmail.com> wrote:

> Use IFLA_AF_SPEC nested attributes to lookup bridge mode and when
> doing strcmp() check for equality.
> 
> These appear to be typos from the original commit,
> 
> commit 64108901b737b95247b53dec8c1b8217ca8505b7
> Author: Vlad Yasevich <vyasevic@redhat.com>
> Date:   Fri Mar 15 10:01:28 2013 -0700
> 
>     bridge: Add support for setting bridge port attributes
> 
> Also set flags to BRIDGE_FLAGS_SELF instead of using OR operation.
> This allows setting the bridge mode when not being used with a
> master device.
> 
> To allow setting both master and self devices simultaneously we
> will need to add a {self|master} field similar to fdb commands.
> For now the command sets are mutually exclusive as noted in the
> original commit.
> 
> With this patch 'bridge link set' works now,
> 
> # ./bridge/bridge link set dev veth1 cost 3
> # ./bridge/bridge link show
> 10: veth1 state UP : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master bridge0 state forwarding priority 3 cost 3
> 
> CC: Vlad Yasevich <vyasevic@redhat.com>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>

Looks good, applied

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-04  2:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29 16:20 [PATCH] iproute2: bridge: fix 'bridge link' setlink/getlink parsing John Fastabend
2013-06-04  2:57 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).