[PATCH iproute2 0/3] dcb: Fixes

STALE2053d

Revision v1 of 2 in this series.

7 messages, 2 authors, 2021-01-03 · open the first message on its own page

[PATCH iproute2 0/3] dcb: Fixes

From: Petr Machata <hidden>
Date: 2021-01-01 23:28:13

dcb currently sends all netlink messages with a type RTM_GETDCB, even the
set ones. In patch #1, send the setters as RTM_SETDCB.

In patch #2, plug a leak.

In patch #3, change the command line option for namespace change from
devlink-like -N / --Netns to ip-like -n / --netns.

Petr Machata (3):
  dcb: Set values with RTM_SETDCB type
  dcb: Plug a leaking DCB socket buffer
  dcb: Change --Netns/-N to --netns/-n

 dcb/dcb.c      | 11 ++++++-----
 man/man8/dcb.8 |  7 +++++++
 2 files changed, 13 insertions(+), 5 deletions(-)

-- 
2.26.2

[PATCH iproute2 2/3] dcb: Plug a leaking DCB socket buffer

From: Petr Machata <hidden>
Date: 2021-01-01 23:28:13

DCB socket buffer is allocated in dcb_init(), but never freed(). Free it
in dcb_fini().

Signed-off-by: Petr Machata <redacted>
---
 dcb/dcb.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/dcb/dcb.c b/dcb/dcb.c
index f5c62790e27e..0e3c87484f2a 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -38,6 +38,7 @@ static void dcb_fini(struct dcb *dcb)
 {
 	delete_json_obj_plain();
 	mnl_socket_close(dcb->nl);
+	free(dcb->buf);
 }
 
 static struct dcb *dcb_alloc(void)
-- 
2.26.2

[PATCH iproute2 1/3] dcb: Set values with RTM_SETDCB type

From: Petr Machata <hidden>
Date: 2021-01-01 23:28:13

dcb currently sends all netlink messages with a type RTM_GETDCB, even the
set ones. Change to the appropriate type.

Signed-off-by: Petr Machata <redacted>
---
 dcb/dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dcb/dcb.c b/dcb/dcb.c
index adec57476e1d..f5c62790e27e 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -177,7 +177,7 @@ int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *da
 	struct nlattr *nest;
 	int ret;
 
-	nlh = dcb_prepare(dcb, dev, RTM_GETDCB, DCB_CMD_IEEE_SET);
+	nlh = dcb_prepare(dcb, dev, RTM_SETDCB, DCB_CMD_IEEE_SET);
 
 	nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE);
 	mnl_attr_put(nlh, attr, data_len, data);
-- 
2.26.2

[PATCH iproute2 3/3] dcb: Change --Netns/-N to --netns/-n

From: Petr Machata <hidden>
Date: 2021-01-01 23:28:13

This to keep compatible with the major tools, ip and tc. Also
document the option in the man page, which was neglected.

Signed-off-by: Petr Machata <redacted>
---
 dcb/dcb.c      | 8 ++++----
 man/man8/dcb.8 | 7 +++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/dcb/dcb.c b/dcb/dcb.c
index 0e3c87484f2a..6640deef5688 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -332,7 +332,7 @@ static void dcb_help(void)
 {
 	fprintf(stderr,
 		"Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n"
-		"       dcb [ -f | --force ] { -b | --batch } filename [ -N | --Netns ] netnsname\n"
+		"       dcb [ -f | --force ] { -b | --batch } filename [ -n | --netns ] netnsname\n"
 		"where  OBJECT := { buffer | ets | maxrate | pfc }\n"
 		"       OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n"
 		"                  | -p | --pretty | -s | --statistics | -v | --verbose]\n");
@@ -379,7 +379,7 @@ int main(int argc, char **argv)
 		{ "json",		no_argument,		NULL, 'j' },
 		{ "pretty",		no_argument,		NULL, 'p' },
 		{ "statistics",		no_argument,		NULL, 's' },
-		{ "Netns",		required_argument,	NULL, 'N' },
+		{ "netns",		required_argument,	NULL, 'n' },
 		{ "help",		no_argument,		NULL, 'h' },
 		{ NULL, 0, NULL, 0 }
 	};
@@ -396,7 +396,7 @@ int main(int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
-	while ((opt = getopt_long(argc, argv, "b:fhijpsvN:V",
+	while ((opt = getopt_long(argc, argv, "b:fhijn:psvV",
 				  long_options, NULL)) >= 0) {
 
 		switch (opt) {
@@ -419,7 +419,7 @@ int main(int argc, char **argv)
 		case 's':
 			dcb->stats = true;
 			break;
-		case 'N':
+		case 'n':
 			if (netns_switch(optarg)) {
 				ret = EXIT_FAILURE;
 				goto dcb_free;
diff --git a/man/man8/dcb.8 b/man/man8/dcb.8
index 5964f25d386d..7293bb303577 100644
--- a/man/man8/dcb.8
+++ b/man/man8/dcb.8
@@ -27,6 +27,13 @@ dcb \- show / manipulate DCB (Data Center Bridging) settings
 
 .SH OPTIONS
 
+.TP
+.BR "\-n" , " \--netns " <NETNS>
+switches
+.B dcb
+to the specified network namespace
+.IR NETNS .
+
 .TP
 .BR "\-V" , " --Version"
 Print the version of the
-- 
2.26.2

Re: [PATCH iproute2 1/3] dcb: Set values with RTM_SETDCB type

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-01-02 17:35:30

On Sat,  2 Jan 2021 00:25:50 +0100
Petr Machata [off-list ref] wrote:
quoted hunk
dcb currently sends all netlink messages with a type RTM_GETDCB, even the
set ones. Change to the appropriate type.

Signed-off-by: Petr Machata <redacted>
---
 dcb/dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dcb/dcb.c b/dcb/dcb.c
index adec57476e1d..f5c62790e27e 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -177,7 +177,7 @@ int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *da
 	struct nlattr *nest;
 	int ret;
 
-	nlh = dcb_prepare(dcb, dev, RTM_GETDCB, DCB_CMD_IEEE_SET);
+	nlh = dcb_prepare(dcb, dev, RTM_SETDCB, DCB_CMD_IEEE_SET);
 
 	nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE);
 	mnl_attr_put(nlh, attr, data_len, data);
Should I add fixes tag to this?

Re: [PATCH iproute2 1/3] dcb: Set values with RTM_SETDCB type

From: Petr Machata <hidden>
Date: 2021-01-03 10:49:24

Stephen Hemminger [off-list ref] writes:
On Sat,  2 Jan 2021 00:25:50 +0100
Petr Machata [off-list ref] wrote:
quoted
dcb currently sends all netlink messages with a type RTM_GETDCB, even the
set ones. Change to the appropriate type.

Signed-off-by: Petr Machata <redacted>
---
 dcb/dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dcb/dcb.c b/dcb/dcb.c
index adec57476e1d..f5c62790e27e 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -177,7 +177,7 @@ int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *da
 	struct nlattr *nest;
 	int ret;
 
-	nlh = dcb_prepare(dcb, dev, RTM_GETDCB, DCB_CMD_IEEE_SET);
+	nlh = dcb_prepare(dcb, dev, RTM_SETDCB, DCB_CMD_IEEE_SET);
 
 	nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE);
 	mnl_attr_put(nlh, attr, data_len, data);
Should I add fixes tag to this?
Ha, I forgot that Fixes: tags are a thing in iproute2. Sorry about that,
I'll resend.

Re: [PATCH iproute2 1/3] dcb: Set values with RTM_SETDCB type

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-01-03 18:23:58

On Sun, 03 Jan 2021 11:47:46 +0100
Petr Machata [off-list ref] wrote:
Stephen Hemminger [off-list ref] writes:
quoted
On Sat,  2 Jan 2021 00:25:50 +0100
Petr Machata [off-list ref] wrote:
 
quoted
dcb currently sends all netlink messages with a type RTM_GETDCB, even the
set ones. Change to the appropriate type.

Signed-off-by: Petr Machata <redacted>
---
 dcb/dcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dcb/dcb.c b/dcb/dcb.c
index adec57476e1d..f5c62790e27e 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -177,7 +177,7 @@ int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *da
 	struct nlattr *nest;
 	int ret;
 
-	nlh = dcb_prepare(dcb, dev, RTM_GETDCB, DCB_CMD_IEEE_SET);
+	nlh = dcb_prepare(dcb, dev, RTM_SETDCB, DCB_CMD_IEEE_SET);
 
 	nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE);
 	mnl_attr_put(nlh, attr, data_len, data);  
Should I add fixes tag to this?  
Ha, I forgot that Fixes: tags are a thing in iproute2. Sorry about that,
I'll resend.
Thanks, Fixes are mainly to help out distribution maintainers who want
to backport to older versions.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help