Skip to contentSkip to conversation

tc: parse attributes with NLA_F_NESTED flag

PATCH Applied Leslie Monis 2 participants 6 messages Jan 16, 2020 – Jan 22, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tc: parse attributes with NLA_F_NESTED flag

The kernel now requires all new nested attributes to set the NLA_F_NESTED flag. Enable tc {qdisc,class,filter} to parse attributes that have the NLA_F_NESTED flag set.

---
 tc/tc_class.c  | 6 +++---
 tc/tc_filter.c | 2 +-
 tc/tc_qdisc.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
tc/tc_class.c +3 -3
index c7e3cfdf..39bea971 100644
@@ -246,8 +246,8 @@ static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
 			 "+---(%s)", cls_id_str);
 		strcat(buf, str);
 
-		parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,
-				cls->data_len);
+		parse_rtattr_flags(tb, TCA_MAX, (struct rtattr *)cls->data,
+				   cls->data_len, NLA_F_NESTED);
 
 		if (tb[TCA_KIND] == NULL) {
 			strcat(buf, " [unknown qdisc kind] ");
@@ -327,7 +327,7 @@ int print_class(struct nlmsghdr *n, void *arg)
 	if (filter_classid && t->tcm_handle != filter_classid)
 		return 0;
 
-	parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
+	parse_rtattr_flags(tb, TCA_MAX, TCA_RTA(t), len, NLA_F_NESTED);
 
 	if (tb[TCA_KIND] == NULL) {
 		fprintf(stderr, "print_class: NULL kind\n");
tc/tc_filter.c +1 -1
index dcddca77..c591a19f 100644
@@ -267,7 +267,7 @@ int print_filter(struct nlmsghdr *n, void *arg)
 		return -1;
 	}
 
-	parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
+	parse_rtattr_flags(tb, TCA_MAX, TCA_RTA(t), len, NLA_F_NESTED);
 
 	if (tb[TCA_KIND] == NULL && (n->nlmsg_type == RTM_NEWTFILTER ||
 				     n->nlmsg_type == RTM_GETTFILTER ||
tc/tc_qdisc.c +2 -2
index 75a14672..181fe2f0 100644
@@ -235,7 +235,7 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
 	if (filter_ifindex && filter_ifindex != t->tcm_ifindex)
 		return 0;
 
-	parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
+	parse_rtattr_flags(tb, TCA_MAX, TCA_RTA(t), len, NLA_F_NESTED);
 
 	if (tb[TCA_KIND] == NULL) {
 		fprintf(stderr, "print_qdisc: NULL kind\n");
@@ -461,7 +461,7 @@ static int tc_qdisc_block_exists_cb(struct nlmsghdr *n, void *arg)
 	if (len < 0)
 		return -1;
 
-	parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
+	parse_rtattr_flags(tb, TCA_MAX, TCA_RTA(t), len, NLA_F_NESTED);
 
 	if (tb[TCA_KIND] == NULL)
 		return -1;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · Leslie Monis

The kernel now requires all new nested attributes to set the NLA_F_NESTED flag. Enable tc {qdisc,class,filter} to parse attributes that have the NLA_F_NESTED flag set.

I apologize. I forgot to add the [iproute2-next] tag.

#2 lore raw
In reply to Leslie Monis

tc/tc_class.c static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list, · line 250

Quoted 12 lines · Leslie Monis
tc/tc_class.c +2 -2
index c7e3cfdf..39bea971 100644
@@ -246,8 +246,8 @@ static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
 			 "+---(%s)", cls_id_str);
 		strcat(buf, str);
 
-		parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,
-				cls->data_len);
+		parse_rtattr_flags(tb, TCA_MAX, (struct rtattr *)cls->data,
+				   cls->data_len, NLA_F_NESTED);

Petr recently sent a patch to update parse_rtattr_nested to add the NESTED flag. Can you update this patch to use parse_rtattr_nested?

#3 lore raw
Quoted 11 lines · David Ahern
Quoted 8 lines · Leslie Monis
tc/tc_class.c +0 -0
index c7e3cfdf..39bea971 100644
@@ -246,8 +246,8 @@ static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
                       "+---(%s)", cls_id_str);
              strcat(buf, str);
 
Quoted 7 lines

tc/tc_class.c static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list, · line 250

Quoted 4 lines
tc/tc_class.c +2 -2
-             parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,
-                             cls->data_len);
+             parse_rtattr_flags(tb, TCA_MAX, (struct rtattr *)cls->data,
+                                cls->data_len, NLA_F_NESTED);

Petr recently sent a patch to update parse_rtattr_nested to add the NESTED flag. Can you update this patch to use parse_rtattr_nested?

Yes, will do.

#4 lore raw
Quoted 21 lines · Leslie Monis
Quoted 11 lines · David Ahern
Quoted 8 lines · Leslie Monis
tc/tc_class.c +0 -0
index c7e3cfdf..39bea971 100644
@@ -246,8 +246,8 @@ static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
                       "+---(%s)", cls_id_str);
              strcat(buf, str);
 
Quoted 7 lines

tc/tc_class.c static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list, · line 250

Quoted 4 lines
tc/tc_class.c +2 -2
-             parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,
-                             cls->data_len);
+             parse_rtattr_flags(tb, TCA_MAX, (struct rtattr *)cls->data,
+                                cls->data_len, NLA_F_NESTED);

Petr recently sent a patch to update parse_rtattr_nested to add the NESTED flag. Can you update this patch to use parse_rtattr_nested?

Quoted 1 line

Yes, will do.

On a second thought, I think this patch should suffice. Using parse_rtattr_nested
does not work in this case as the object that is being parsed is not a nested attribute, but a set of attributes placed contiguously in memory.

If I'm not mistaken, Petr's patch allows parsing nested attributes (with the NLA_F_NESTED flag set) within a nested attribute.

Adding the NLA_F_NESTED flag to parse_rtattr_flags() enables the function to correctly parse those attributes (among the set of attributes) that happen to have the NLA_F_NESTED flag set.

Hope I'm making sense.

Applied
#5 lore raw
In reply to Leslie Monis
Quoted 11 lines · Leslie Monis

The kernel now requires all new nested attributes to set the NLA_F_NESTED flag. Enable tc {qdisc,class,filter} to parse attributes that have the NLA_F_NESTED flag set.

---
 tc/tc_class.c  | 6 +++---
 tc/tc_filter.c | 2 +-
 tc/tc_qdisc.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

applied to iproute2-next. Thanks