Skip to contentSkip to conversation

Handle netdev group for veth peer too

PATCH In review Sergey Popovich 2 participants 3 messages Dec 11, 2013 – Dec 20, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 Initialize arguments to iplink_parse() by default

Be consistent when dealing with arguments passed to iplink_parse() by initializing to default values.

This fixes crash when ip-link(8) invoced with command:

ip link add dev veth1a type veth peer

---
 ip/iplink.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
ip/iplink.c +3 -6
index 58b6c20..9735c54 100644
@@ -299,6 +299,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 	int numtxqueues = -1;
 	int numrxqueues = -1;
 
+	*name = *type = *link = *dev = NULL;
 	*group = -1;
 	ret = argc;
 
@@ -498,15 +499,11 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 
 static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 {
-	int len;
-	char *dev = NULL;
-	char *name = NULL;
-	char *link = NULL;
-	char *type = NULL;
+	char *name, *type, *link, *dev;
 	int group;
 	struct link_util *lu = NULL;
 	struct iplink_req req;
-	int ret;
+	int len, ret;
 
 	memset(&req, 0, sizeof(req));
 
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH 1/2] Initialize arguments to iplink_parse() by default

Quoted 8 lines

Be consistent when dealing with arguments passed to iplink_parse() by initializing to default values.

This fixes crash when ip-link(8) invoced with command:

ip link add dev veth1a type veth peer

Rather than modifying iplink_parse, I just fixed in veth code where the bug was being caused.

#3 lore raw

PATCH 2/2 Handle netdev group for veth peer too

In reply to a message not in the archive

Currently ip-link(8) parses, but ignores "group" argument to peer interface on veth creation.

Insert IFLA_GROUP attribute for peer interface when present.

---
 ip/link_veth.c |    3 +++
 1 file changed, 3 insertions(+)
ip/link_veth.c +3 -0
index 7730f39..98ff6a5 100644
@@ -53,6 +53,9 @@ static int veth_parse_opt(struct link_util *lu, int argc, char **argv,
 		addattr_l(hdr, 1024, IFLA_IFNAME, name, len);
 	}
 
+	if (group != -1)
+		addattr32(hdr, 1024, IFLA_GROUP, group);
+
 	data->rta_len = (void *)NLMSG_TAIL(hdr) - (void *)data;
 	return argc - 1 - err;
 }
Signature · 1 line
1.7.10.4