提交 f8edcd12 编写于 作者: P Phil Sutter 提交者: David S. Miller

net: rtnetlink: Don't export empty RTAX_FEATURES

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: NPhil Sutter <phil@nwl.cc>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 e7b48a32
...@@ -704,6 +704,8 @@ int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics) ...@@ -704,6 +704,8 @@ int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
} else if (i == RTAX_FEATURES - 1) { } else if (i == RTAX_FEATURES - 1) {
u32 user_features = metrics[i] & RTAX_FEATURE_MASK; u32 user_features = metrics[i] & RTAX_FEATURE_MASK;
if (!user_features)
continue;
BUILD_BUG_ON(RTAX_FEATURE_MASK & DST_FEATURE_MASK); BUILD_BUG_ON(RTAX_FEATURE_MASK & DST_FEATURE_MASK);
if (nla_put_u32(skb, i + 1, user_features)) if (nla_put_u32(skb, i + 1, user_features))
goto nla_put_failure; goto nla_put_failure;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册