vxlan: make the struct nlattr variable const
Subsystems (2)
PATCH 1/1 vxlan: make the struct nlattr variable const
From: Zhu Yanjun <[email protected]>
The struct nlattr variable should not be changed.
Signed-off-by Zhu Yanjun <[email protected]>
--- drivers/net/vxlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/vxlan.c +2 -2
@@ -115,7 +115,7 @@ static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa)return IN_MULTICAST (ntohl (ipa->sin.sin_addr.s_addr)); } -static int vxlan_nla_get_addr (union vxlan_addr *ip,struct nlattr *nla) +static int vxlan_nla_get_addr (union vxlan_addr *ip,const struct nlattr *nla) {if (nla_len (nla) >=sizeof (struct in6_addr )) { ip->sin6.sin6_addr =nla_get_in6_addr (nla);
@@ -157,7 +157,7 @@ static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa)return IN_MULTICAST (ntohl (ipa->sin.sin_addr.s_addr)); } -static int vxlan_nla_get_addr (union vxlan_addr *ip,struct nlattr *nla) +static int vxlan_nla_get_addr (union vxlan_addr *ip,const struct nlattr *nla) {if (nla_len (nla) >=sizeof (struct in6_addr )) {return -EAFNOSUPPORT ;
Signature · 1 line
2.7.4
Quoted 3 lines · On Sat, 3 Sep 2016 22:07:10 +0800, [email protected] wrote:
From: Zhu Yanjun <[email protected]>
The struct nlattr variable should not be changed.
True. But the only caller is vxlan_fdb_parse which doesn't have its tb parameter const, so what's the point?
Now, the tb parameter of vxlan_fdb_parse could be changed to const. This again doesn't make much sense without modifying its callers, which are vxlan_fdb_add and vxlan_fdb_delete. And those are net_device_ops hooks. Have you considered looking into those (ndo_fdb_*) and turning the struct nlattr ** to const (that is, if it's possible)?
Jiri