Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lwtunnel: Pass encap and encap type attributes to lwtunnel_fill_encap

Currently, lwtunnel_fill_encap hardcodes the encap and encap type
attributes as RTA_ENCAP and RTA_ENCAP_TYPE, respectively. The nexthop
objects want to re-use this code but the encap attributes passed to
userspace as NHA_ENCAP and NHA_ENCAP_TYPE. Since that is the only
difference, change lwtunnel_fill_encap to take the attribute type as
an input.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

David Ahern and committed by
David S. Miller
ffa8ce54 0a5d329f

+10 -7
+4 -3
include/net/lwtunnel.h
··· 118 118 unsigned int family, const void *cfg, 119 119 struct lwtunnel_state **lws, 120 120 struct netlink_ext_ack *extack); 121 - int lwtunnel_fill_encap(struct sk_buff *skb, 122 - struct lwtunnel_state *lwtstate); 121 + int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate, 122 + int encap_attr, int encap_type_attr); 123 123 int lwtunnel_get_encap_size(struct lwtunnel_state *lwtstate); 124 124 struct lwtunnel_state *lwtunnel_state_alloc(int hdr_len); 125 125 int lwtunnel_cmp_encap(struct lwtunnel_state *a, struct lwtunnel_state *b); ··· 219 219 } 220 220 221 221 static inline int lwtunnel_fill_encap(struct sk_buff *skb, 222 - struct lwtunnel_state *lwtstate) 222 + struct lwtunnel_state *lwtstate, 223 + int encap_attr, int encap_type_attr) 223 224 { 224 225 return 0; 225 226 }
+4 -3
net/core/lwtunnel.c
··· 223 223 } 224 224 EXPORT_SYMBOL_GPL(lwtstate_free); 225 225 226 - int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate) 226 + int lwtunnel_fill_encap(struct sk_buff *skb, struct lwtunnel_state *lwtstate, 227 + int encap_attr, int encap_type_attr) 227 228 { 228 229 const struct lwtunnel_encap_ops *ops; 229 230 struct nlattr *nest; ··· 237 236 lwtstate->type > LWTUNNEL_ENCAP_MAX) 238 237 return 0; 239 238 240 - nest = nla_nest_start(skb, RTA_ENCAP); 239 + nest = nla_nest_start(skb, encap_attr); 241 240 if (!nest) 242 241 return -EMSGSIZE; 243 242 ··· 251 250 if (ret) 252 251 goto nla_put_failure; 253 252 nla_nest_end(skb, nest); 254 - ret = nla_put_u16(skb, RTA_ENCAP_TYPE, lwtstate->type); 253 + ret = nla_put_u16(skb, encap_type_attr, lwtstate->type); 255 254 if (ret) 256 255 goto nla_put_failure; 257 256
+2 -1
net/ipv4/fib_semantics.c
··· 1503 1503 goto nla_put_failure; 1504 1504 1505 1505 if (nhc->nhc_lwtstate && 1506 - lwtunnel_fill_encap(skb, nhc->nhc_lwtstate) < 0) 1506 + lwtunnel_fill_encap(skb, nhc->nhc_lwtstate, 1507 + RTA_ENCAP, RTA_ENCAP_TYPE) < 0) 1507 1508 goto nla_put_failure; 1508 1509 1509 1510 return 0;