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

net: add net available in build_state

The build_state callback of lwtunnel doesn't contain the net namespace
structure yet. This patch will add it so we can check on specific
address configuration at creation time of rpl source routes.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alexander Aring and committed by
David S. Miller
faee6769 8610c7c6

+32 -28
+3 -2
include/net/ip_fib.h
··· 470 470 struct fib_config *cfg, int nh_weight, 471 471 struct netlink_ext_ack *extack); 472 472 void fib_nh_release(struct net *net, struct fib_nh *fib_nh); 473 - int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *fc_encap, 474 - u16 fc_encap_type, void *cfg, gfp_t gfp_flags, 473 + int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc, 474 + struct nlattr *fc_encap, u16 fc_encap_type, 475 + void *cfg, gfp_t gfp_flags, 475 476 struct netlink_ext_ack *extack); 476 477 void fib_nh_common_release(struct fib_nh_common *nhc); 477 478
+3 -3
include/net/lwtunnel.h
··· 34 34 }; 35 35 36 36 struct lwtunnel_encap_ops { 37 - int (*build_state)(struct nlattr *encap, 37 + int (*build_state)(struct net *net, struct nlattr *encap, 38 38 unsigned int family, const void *cfg, 39 39 struct lwtunnel_state **ts, 40 40 struct netlink_ext_ack *extack); ··· 113 113 struct netlink_ext_ack *extack); 114 114 int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len, 115 115 struct netlink_ext_ack *extack); 116 - int lwtunnel_build_state(u16 encap_type, 116 + int lwtunnel_build_state(struct net *net, u16 encap_type, 117 117 struct nlattr *encap, 118 118 unsigned int family, const void *cfg, 119 119 struct lwtunnel_state **lws, ··· 209 209 return 0; 210 210 } 211 211 212 - static inline int lwtunnel_build_state(u16 encap_type, 212 + static inline int lwtunnel_build_state(struct net *net, u16 encap_type, 213 213 struct nlattr *encap, 214 214 unsigned int family, const void *cfg, 215 215 struct lwtunnel_state **lws,
+1 -1
net/core/lwt_bpf.c
··· 367 367 [LWT_BPF_XMIT_HEADROOM] = { .type = NLA_U32 }, 368 368 }; 369 369 370 - static int bpf_build_state(struct nlattr *nla, 370 + static int bpf_build_state(struct net *net, struct nlattr *nla, 371 371 unsigned int family, const void *cfg, 372 372 struct lwtunnel_state **ts, 373 373 struct netlink_ext_ack *extack)
+2 -2
net/core/lwtunnel.c
··· 98 98 } 99 99 EXPORT_SYMBOL_GPL(lwtunnel_encap_del_ops); 100 100 101 - int lwtunnel_build_state(u16 encap_type, 101 + int lwtunnel_build_state(struct net *net, u16 encap_type, 102 102 struct nlattr *encap, unsigned int family, 103 103 const void *cfg, struct lwtunnel_state **lws, 104 104 struct netlink_ext_ack *extack) ··· 122 122 rcu_read_unlock(); 123 123 124 124 if (found) { 125 - ret = ops->build_state(encap, family, cfg, lws, extack); 125 + ret = ops->build_state(net, encap, family, cfg, lws, extack); 126 126 if (ret) 127 127 module_put(ops->owner); 128 128 } else {
+1 -1
net/ipv4/fib_lookup.h
··· 35 35 void fib_release_info(struct fib_info *); 36 36 struct fib_info *fib_create_info(struct fib_config *cfg, 37 37 struct netlink_ext_ack *extack); 38 - int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, 38 + int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi, 39 39 struct netlink_ext_ack *extack); 40 40 bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi); 41 41 int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
+12 -10
net/ipv4/fib_semantics.c
··· 570 570 return 1; 571 571 } 572 572 573 - int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap, 574 - u16 encap_type, void *cfg, gfp_t gfp_flags, 573 + int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc, 574 + struct nlattr *encap, u16 encap_type, 575 + void *cfg, gfp_t gfp_flags, 575 576 struct netlink_ext_ack *extack) 576 577 { 577 578 int err; ··· 590 589 err = -EINVAL; 591 590 goto lwt_failure; 592 591 } 593 - err = lwtunnel_build_state(encap_type, encap, nhc->nhc_family, 594 - cfg, &lwtstate, extack); 592 + err = lwtunnel_build_state(net, encap_type, encap, 593 + nhc->nhc_family, cfg, &lwtstate, 594 + extack); 595 595 if (err) 596 596 goto lwt_failure; 597 597 ··· 616 614 617 615 nh->fib_nh_family = AF_INET; 618 616 619 - err = fib_nh_common_init(&nh->nh_common, cfg->fc_encap, 617 + err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap, 620 618 cfg->fc_encap_type, cfg, GFP_KERNEL, extack); 621 619 if (err) 622 620 return err; ··· 816 814 817 815 #endif /* CONFIG_IP_ROUTE_MULTIPATH */ 818 816 819 - static int fib_encap_match(u16 encap_type, 817 + static int fib_encap_match(struct net *net, u16 encap_type, 820 818 struct nlattr *encap, 821 819 const struct fib_nh *nh, 822 820 const struct fib_config *cfg, ··· 828 826 if (encap_type == LWTUNNEL_ENCAP_NONE) 829 827 return 0; 830 828 831 - ret = lwtunnel_build_state(encap_type, encap, AF_INET, 829 + ret = lwtunnel_build_state(net, encap_type, encap, AF_INET, 832 830 cfg, &lwtstate, extack); 833 831 if (!ret) { 834 832 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); ··· 838 836 return result; 839 837 } 840 838 841 - int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, 839 + int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi, 842 840 struct netlink_ext_ack *extack) 843 841 { 844 842 #ifdef CONFIG_IP_ROUTE_MULTIPATH ··· 859 857 struct fib_nh *nh = fib_info_nh(fi, 0); 860 858 861 859 if (cfg->fc_encap) { 862 - if (fib_encap_match(cfg->fc_encap_type, cfg->fc_encap, 863 - nh, cfg, extack)) 860 + if (fib_encap_match(net, cfg->fc_encap_type, 861 + cfg->fc_encap, nh, cfg, extack)) 864 862 return 1; 865 863 } 866 864 #ifdef CONFIG_IP_ROUTE_CLASSID
+1 -1
net/ipv4/fib_trie.c
··· 1679 1679 fi->fib_prefsrc == cfg->fc_prefsrc) && 1680 1680 (!cfg->fc_protocol || 1681 1681 fi->fib_protocol == cfg->fc_protocol) && 1682 - fib_nh_match(cfg, fi, extack) == 0 && 1682 + fib_nh_match(net, cfg, fi, extack) == 0 && 1683 1683 fib_metrics_match(cfg, fi)) { 1684 1684 fa_to_delete = fa; 1685 1685 break;
+2 -2
net/ipv4/ip_tunnel_core.c
··· 432 432 return ip_tun_parse_opts(attr, info, extack); 433 433 } 434 434 435 - static int ip_tun_build_state(struct nlattr *attr, 435 + static int ip_tun_build_state(struct net *net, struct nlattr *attr, 436 436 unsigned int family, const void *cfg, 437 437 struct lwtunnel_state **ts, 438 438 struct netlink_ext_ack *extack) ··· 719 719 [LWTUNNEL_IP6_OPTS] = { .type = NLA_NESTED }, 720 720 }; 721 721 722 - static int ip6_tun_build_state(struct nlattr *attr, 722 + static int ip6_tun_build_state(struct net *net, struct nlattr *attr, 723 723 unsigned int family, const void *cfg, 724 724 struct lwtunnel_state **ts, 725 725 struct netlink_ext_ack *extack)
+1 -1
net/ipv6/ila/ila_lwt.c
··· 125 125 [ILA_ATTR_HOOK_TYPE] = { .type = NLA_U8, }, 126 126 }; 127 127 128 - static int ila_build_state(struct nlattr *nla, 128 + static int ila_build_state(struct net *net, struct nlattr *nla, 129 129 unsigned int family, const void *cfg, 130 130 struct lwtunnel_state **ts, 131 131 struct netlink_ext_ack *extack)
+1 -1
net/ipv6/route.c
··· 3471 3471 !netif_carrier_ok(dev)) 3472 3472 fib6_nh->fib_nh_flags |= RTNH_F_LINKDOWN; 3473 3473 3474 - err = fib_nh_common_init(&fib6_nh->nh_common, cfg->fc_encap, 3474 + err = fib_nh_common_init(net, &fib6_nh->nh_common, cfg->fc_encap, 3475 3475 cfg->fc_encap_type, cfg, gfp_flags, extack); 3476 3476 if (err) 3477 3477 goto out;
+1 -1
net/ipv6/seg6_iptunnel.c
··· 376 376 return err; 377 377 } 378 378 379 - static int seg6_build_state(struct nlattr *nla, 379 + static int seg6_build_state(struct net *net, struct nlattr *nla, 380 380 unsigned int family, const void *cfg, 381 381 struct lwtunnel_state **ts, 382 382 struct netlink_ext_ack *extack)
+3 -2
net/ipv6/seg6_local.c
··· 970 970 return 0; 971 971 } 972 972 973 - static int seg6_local_build_state(struct nlattr *nla, unsigned int family, 974 - const void *cfg, struct lwtunnel_state **ts, 973 + static int seg6_local_build_state(struct net *net, struct nlattr *nla, 974 + unsigned int family, const void *cfg, 975 + struct lwtunnel_state **ts, 975 976 struct netlink_ext_ack *extack) 976 977 { 977 978 struct nlattr *tb[SEG6_LOCAL_MAX + 1];
+1 -1
net/mpls/mpls_iptunnel.c
··· 162 162 return -EINVAL; 163 163 } 164 164 165 - static int mpls_build_state(struct nlattr *nla, 165 + static int mpls_build_state(struct net *net, struct nlattr *nla, 166 166 unsigned int family, const void *cfg, 167 167 struct lwtunnel_state **ts, 168 168 struct netlink_ext_ack *extack)