[net-next PATCH] net: rtnetlink: Don't export empty RTAX_FEATURES

Subsystems: networking [general], the rest

STALE3668d

2 messages, 2 authors, 2016-08-24 · open the first message on its own page

[net-next PATCH] net: rtnetlink: Don't export empty RTAX_FEATURES

From: Phil Sutter <phil@nwl.cc>
Date: 2016-08-23 11:23:11

Since the features bit field has bits for internal only use as well, it
may happen that the kernel exports RTAX_FEATURES attribute with zero
value which is pointless.

Fix this by making sure the attribute is added only if the exported
value is non-zero.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 net/core/rtnetlink.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 189cc78c77eba..318fc5231b2b4 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -704,6 +704,8 @@ int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
 			} else if (i == RTAX_FEATURES - 1) {
 				u32 user_features = metrics[i] & RTAX_FEATURE_MASK;
 
+				if (!user_features)
+					continue;
 				BUILD_BUG_ON(RTAX_FEATURE_MASK & DST_FEATURE_MASK);
 				if (nla_put_u32(skb, i + 1, user_features))
 					goto nla_put_failure;
-- 
2.8.2

Re: [net-next PATCH] net: rtnetlink: Don't export empty RTAX_FEATURES

From: David Miller <davem@davemloft.net>
Date: 2016-08-24 00:09:44

From: Phil Sutter <phil@nwl.cc>
Date: Tue, 23 Aug 2016 13:14:31 +0200
Since the features bit field has bits for internal only use as well, it
may happen that the kernel exports RTAX_FEATURES attribute with zero
value which is pointless.

Fix this by making sure the attribute is added only if the exported
value is non-zero.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help