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

lwtunnel: remove device arg to lwtunnel_build_state

Nothing about lwt state requires a device reference, so remove the
input argument.

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

authored by

David Ahern and committed by
David S. Miller
30357d7d 6ad20165

+20 -31
+3 -3
include/net/lwtunnel.h
··· 33 33 }; 34 34 35 35 struct lwtunnel_encap_ops { 36 - int (*build_state)(struct net_device *dev, struct nlattr *encap, 36 + int (*build_state)(struct nlattr *encap, 37 37 unsigned int family, const void *cfg, 38 38 struct lwtunnel_state **ts); 39 39 void (*destroy_state)(struct lwtunnel_state *lws); ··· 109 109 unsigned int num); 110 110 int lwtunnel_valid_encap_type(u16 encap_type); 111 111 int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len); 112 - int lwtunnel_build_state(struct net_device *dev, u16 encap_type, 112 + int lwtunnel_build_state(u16 encap_type, 113 113 struct nlattr *encap, 114 114 unsigned int family, const void *cfg, 115 115 struct lwtunnel_state **lws); ··· 181 181 return -EOPNOTSUPP; 182 182 } 183 183 184 - static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type, 184 + static inline int lwtunnel_build_state(u16 encap_type, 185 185 struct nlattr *encap, 186 186 unsigned int family, const void *cfg, 187 187 struct lwtunnel_state **lws)
+1 -1
net/core/lwt_bpf.c
··· 237 237 [LWT_BPF_XMIT_HEADROOM] = { .type = NLA_U32 }, 238 238 }; 239 239 240 - static int bpf_build_state(struct net_device *dev, struct nlattr *nla, 240 + static int bpf_build_state(struct nlattr *nla, 241 241 unsigned int family, const void *cfg, 242 242 struct lwtunnel_state **ts) 243 243 {
+2 -2
net/core/lwtunnel.c
··· 101 101 } 102 102 EXPORT_SYMBOL(lwtunnel_encap_del_ops); 103 103 104 - int lwtunnel_build_state(struct net_device *dev, u16 encap_type, 104 + int lwtunnel_build_state(u16 encap_type, 105 105 struct nlattr *encap, unsigned int family, 106 106 const void *cfg, struct lwtunnel_state **lws) 107 107 { ··· 116 116 rcu_read_lock(); 117 117 ops = rcu_dereference(lwtun_encaps[encap_type]); 118 118 if (likely(ops && ops->build_state && try_module_get(ops->owner))) { 119 - ret = ops->build_state(dev, encap, family, cfg, lws); 119 + ret = ops->build_state(encap, family, cfg, lws); 120 120 if (ret) 121 121 module_put(ops->owner); 122 122 }
+8 -19
net/ipv4/fib_semantics.c
··· 471 471 static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, 472 472 int remaining, struct fib_config *cfg) 473 473 { 474 - struct net *net = cfg->fc_nlinfo.nl_net; 475 474 int ret; 476 475 477 476 change_nexthops(fi) { ··· 502 503 nla = nla_find(attrs, attrlen, RTA_ENCAP); 503 504 if (nla) { 504 505 struct lwtunnel_state *lwtstate; 505 - struct net_device *dev = NULL; 506 506 struct nlattr *nla_entype; 507 507 508 508 nla_entype = nla_find(attrs, attrlen, 509 509 RTA_ENCAP_TYPE); 510 510 if (!nla_entype) 511 511 goto err_inval; 512 - if (cfg->fc_oif) 513 - dev = __dev_get_by_index(net, cfg->fc_oif); 514 - ret = lwtunnel_build_state(dev, nla_get_u16( 512 + 513 + ret = lwtunnel_build_state(nla_get_u16( 515 514 nla_entype), 516 515 nla, AF_INET, cfg, 517 516 &lwtstate); ··· 594 597 595 598 #endif /* CONFIG_IP_ROUTE_MULTIPATH */ 596 599 597 - static int fib_encap_match(struct net *net, u16 encap_type, 600 + static int fib_encap_match(u16 encap_type, 598 601 struct nlattr *encap, 599 - int oif, const struct fib_nh *nh, 602 + const struct fib_nh *nh, 600 603 const struct fib_config *cfg) 601 604 { 602 605 struct lwtunnel_state *lwtstate; 603 - struct net_device *dev = NULL; 604 606 int ret, result = 0; 605 607 606 608 if (encap_type == LWTUNNEL_ENCAP_NONE) 607 609 return 0; 608 610 609 - if (oif) 610 - dev = __dev_get_by_index(net, oif); 611 - ret = lwtunnel_build_state(dev, encap_type, encap, 611 + ret = lwtunnel_build_state(encap_type, encap, 612 612 AF_INET, cfg, &lwtstate); 613 613 if (!ret) { 614 614 result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate); ··· 617 623 618 624 int fib_nh_match(struct fib_config *cfg, struct fib_info *fi) 619 625 { 620 - struct net *net = cfg->fc_nlinfo.nl_net; 621 626 #ifdef CONFIG_IP_ROUTE_MULTIPATH 622 627 struct rtnexthop *rtnh; 623 628 int remaining; ··· 627 634 628 635 if (cfg->fc_oif || cfg->fc_gw) { 629 636 if (cfg->fc_encap) { 630 - if (fib_encap_match(net, cfg->fc_encap_type, 631 - cfg->fc_encap, cfg->fc_oif, 632 - fi->fib_nh, cfg)) 637 + if (fib_encap_match(cfg->fc_encap_type, 638 + cfg->fc_encap, fi->fib_nh, cfg)) 633 639 return 1; 634 640 } 635 641 if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && ··· 1085 1093 1086 1094 if (cfg->fc_encap) { 1087 1095 struct lwtunnel_state *lwtstate; 1088 - struct net_device *dev = NULL; 1089 1096 1090 1097 if (cfg->fc_encap_type == LWTUNNEL_ENCAP_NONE) 1091 1098 goto err_inval; 1092 - if (cfg->fc_oif) 1093 - dev = __dev_get_by_index(net, cfg->fc_oif); 1094 - err = lwtunnel_build_state(dev, cfg->fc_encap_type, 1099 + err = lwtunnel_build_state(cfg->fc_encap_type, 1095 1100 cfg->fc_encap, AF_INET, cfg, 1096 1101 &lwtstate); 1097 1102 if (err)
+2 -2
net/ipv4/ip_tunnel_core.c
··· 226 226 [LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 }, 227 227 }; 228 228 229 - static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, 229 + static int ip_tun_build_state(struct nlattr *attr, 230 230 unsigned int family, const void *cfg, 231 231 struct lwtunnel_state **ts) 232 232 { ··· 323 323 [LWTUNNEL_IP6_FLAGS] = { .type = NLA_U16 }, 324 324 }; 325 325 326 - static int ip6_tun_build_state(struct net_device *dev, struct nlattr *attr, 326 + static int ip6_tun_build_state(struct nlattr *attr, 327 327 unsigned int family, const void *cfg, 328 328 struct lwtunnel_state **ts) 329 329 {
+1 -1
net/ipv6/ila/ila_lwt.c
··· 115 115 [ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, }, 116 116 }; 117 117 118 - static int ila_build_state(struct net_device *dev, struct nlattr *nla, 118 + static int ila_build_state(struct nlattr *nla, 119 119 unsigned int family, const void *cfg, 120 120 struct lwtunnel_state **ts) 121 121 {
+1 -1
net/ipv6/route.c
··· 1897 1897 if (cfg->fc_encap) { 1898 1898 struct lwtunnel_state *lwtstate; 1899 1899 1900 - err = lwtunnel_build_state(dev, cfg->fc_encap_type, 1900 + err = lwtunnel_build_state(cfg->fc_encap_type, 1901 1901 cfg->fc_encap, AF_INET6, cfg, 1902 1902 &lwtstate); 1903 1903 if (err)
+1 -1
net/ipv6/seg6_iptunnel.c
··· 303 303 return err; 304 304 } 305 305 306 - static int seg6_build_state(struct net_device *dev, struct nlattr *nla, 306 + static int seg6_build_state(struct nlattr *nla, 307 307 unsigned int family, const void *cfg, 308 308 struct lwtunnel_state **ts) 309 309 {
+1 -1
net/mpls/mpls_iptunnel.c
··· 133 133 return -EINVAL; 134 134 } 135 135 136 - static int mpls_build_state(struct net_device *dev, struct nlattr *nla, 136 + static int mpls_build_state(struct nlattr *nla, 137 137 unsigned int family, const void *cfg, 138 138 struct lwtunnel_state **ts) 139 139 {