Lines Matching refs:net

51 static int __net_init fib4_rules_init(struct net *net)  in fib4_rules_init()  argument
64 &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX]); in fib4_rules_init()
66 &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX]); in fib4_rules_init()
75 struct fib_table *fib_new_table(struct net *net, u32 id) in fib_new_table() argument
82 tb = fib_get_table(net, id); in fib_new_table()
87 alias = fib_new_table(net, RT_TABLE_MAIN); in fib_new_table()
95 rcu_assign_pointer(net->ipv4.fib_local, tb); in fib_new_table()
98 rcu_assign_pointer(net->ipv4.fib_main, tb); in fib_new_table()
101 rcu_assign_pointer(net->ipv4.fib_default, tb); in fib_new_table()
108 hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]); in fib_new_table()
113 struct fib_table *fib_get_table(struct net *net, u32 id) in fib_get_table() argument
123 head = &net->ipv4.fib_table_hash[h]; in fib_get_table()
132 static void fib_replace_table(struct net *net, struct fib_table *old, in fib_replace_table() argument
138 rcu_assign_pointer(net->ipv4.fib_local, new); in fib_replace_table()
141 rcu_assign_pointer(net->ipv4.fib_main, new); in fib_replace_table()
144 rcu_assign_pointer(net->ipv4.fib_default, new); in fib_replace_table()
155 int fib_unmerge(struct net *net) in fib_unmerge() argument
160 old = fib_get_table(net, RT_TABLE_LOCAL); in fib_unmerge()
170 fib_replace_table(net, old, new); in fib_unmerge()
177 static void fib_flush(struct net *net) in fib_flush() argument
183 struct hlist_head *head = &net->ipv4.fib_table_hash[h]; in fib_flush()
192 rt_cache_flush(net); in fib_flush()
195 void fib_flush_external(struct net *net) in fib_flush_external() argument
202 head = &net->ipv4.fib_table_hash[h]; in fib_flush_external()
212 static inline unsigned int __inet_dev_addr_type(struct net *net, in __inet_dev_addr_type() argument
228 local_table = fib_get_table(net, RT_TABLE_LOCAL); in __inet_dev_addr_type()
241 unsigned int inet_addr_type(struct net *net, __be32 addr) in inet_addr_type() argument
243 return __inet_dev_addr_type(net, NULL, addr); in inet_addr_type()
247 unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev, in inet_dev_addr_type() argument
250 return __inet_dev_addr_type(net, dev, addr); in inet_dev_addr_type()
261 struct net *net; in fib_compute_spec_dst() local
272 net = dev_net(dev); in fib_compute_spec_dst()
283 if (!fib_lookup(net, &fl4, &res)) in fib_compute_spec_dst()
284 return FIB_RES_PREFSRC(net, res); in fib_compute_spec_dst()
307 struct net *net; in __fib_validate_source() local
321 net = dev_net(dev); in __fib_validate_source()
322 if (fib_lookup(net, &fl4, &res)) in __fib_validate_source()
357 if (fib_lookup(net, &fl4, &res) == 0) { in __fib_validate_source()
408 static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, in rtentry_to_fib_config() argument
415 cfg->fc_nlinfo.nl_net = net; in rtentry_to_fib_config()
476 dev = __dev_get_by_name(net, devname); in rtentry_to_fib_config()
499 inet_addr_type(net, addr) == RTN_UNICAST) in rtentry_to_fib_config()
540 int ip_rt_ioctl(struct net *net, unsigned int cmd, void __user *arg) in ip_rt_ioctl() argument
549 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in ip_rt_ioctl()
556 err = rtentry_to_fib_config(net, cmd, &rt, &cfg); in ip_rt_ioctl()
561 tb = fib_get_table(net, cfg.fc_table); in ip_rt_ioctl()
567 tb = fib_new_table(net, cfg.fc_table); in ip_rt_ioctl()
596 static int rtm_to_fib_config(struct net *net, struct sk_buff *skb, in rtm_to_fib_config() argument
621 cfg->fc_nlinfo.nl_net = net; in rtm_to_fib_config()
669 struct net *net = sock_net(skb->sk); in inet_rtm_delroute() local
674 err = rtm_to_fib_config(net, skb, nlh, &cfg); in inet_rtm_delroute()
678 tb = fib_get_table(net, cfg.fc_table); in inet_rtm_delroute()
691 struct net *net = sock_net(skb->sk); in inet_rtm_newroute() local
696 err = rtm_to_fib_config(net, skb, nlh, &cfg); in inet_rtm_newroute()
700 tb = fib_new_table(net, cfg.fc_table); in inet_rtm_newroute()
713 struct net *net = sock_net(skb->sk); in inet_dump_fib() local
731 head = &net->ipv4.fib_table_hash[h]; in inet_dump_fib()
762 struct net *net = dev_net(ifa->ifa_dev->dev); in fib_magic() local
773 .nl_net = net, in fib_magic()
778 tb = fib_new_table(net, RT_TABLE_MAIN); in fib_magic()
780 tb = fib_new_table(net, RT_TABLE_LOCAL); in fib_magic()
984 static void nl_fib_lookup(struct net *net, struct fib_result_nl *frn) in nl_fib_lookup() argument
998 tb = fib_get_table(net, frn->tb_id_in); in nl_fib_lookup()
1021 struct net *net; in nl_fib_input() local
1026 net = sock_net(skb->sk); in nl_fib_input()
1038 nl_fib_lookup(net, frn); in nl_fib_input()
1043 netlink_unicast(net->ipv4.fibnl, skb, portid, MSG_DONTWAIT); in nl_fib_input()
1046 static int __net_init nl_fib_lookup_init(struct net *net) in nl_fib_lookup_init() argument
1053 sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, &cfg); in nl_fib_lookup_init()
1056 net->ipv4.fibnl = sk; in nl_fib_lookup_init()
1060 static void nl_fib_lookup_exit(struct net *net) in nl_fib_lookup_exit() argument
1062 netlink_kernel_release(net->ipv4.fibnl); in nl_fib_lookup_exit()
1063 net->ipv4.fibnl = NULL; in nl_fib_lookup_exit()
1078 struct net *net = dev_net(dev); in fib_inetaddr_event() local
1086 atomic_inc(&net->ipv4.dev_addr_genid); in fib_inetaddr_event()
1091 atomic_inc(&net->ipv4.dev_addr_genid); in fib_inetaddr_event()
1109 struct net *net = dev_net(dev); in fib_netdev_event() local
1129 atomic_inc(&net->ipv4.dev_addr_genid); in fib_netdev_event()
1130 rt_cache_flush(net); in fib_netdev_event()
1137 rt_cache_flush(net); in fib_netdev_event()
1151 static int __net_init ip_fib_net_init(struct net *net) in ip_fib_net_init() argument
1159 net->ipv4.fib_table_hash = kzalloc(size, GFP_KERNEL); in ip_fib_net_init()
1160 if (!net->ipv4.fib_table_hash) in ip_fib_net_init()
1163 err = fib4_rules_init(net); in ip_fib_net_init()
1169 kfree(net->ipv4.fib_table_hash); in ip_fib_net_init()
1173 static void ip_fib_net_exit(struct net *net) in ip_fib_net_exit() argument
1179 RCU_INIT_POINTER(net->ipv4.fib_local, NULL); in ip_fib_net_exit()
1180 RCU_INIT_POINTER(net->ipv4.fib_main, NULL); in ip_fib_net_exit()
1181 RCU_INIT_POINTER(net->ipv4.fib_default, NULL); in ip_fib_net_exit()
1184 struct hlist_head *head = &net->ipv4.fib_table_hash[i]; in ip_fib_net_exit()
1196 fib4_rules_exit(net); in ip_fib_net_exit()
1199 kfree(net->ipv4.fib_table_hash); in ip_fib_net_exit()
1202 static int __net_init fib_net_init(struct net *net) in fib_net_init() argument
1207 net->ipv4.fib_num_tclassid_users = 0; in fib_net_init()
1209 error = ip_fib_net_init(net); in fib_net_init()
1212 error = nl_fib_lookup_init(net); in fib_net_init()
1215 error = fib_proc_init(net); in fib_net_init()
1222 nl_fib_lookup_exit(net); in fib_net_init()
1224 ip_fib_net_exit(net); in fib_net_init()
1228 static void __net_exit fib_net_exit(struct net *net) in fib_net_exit() argument
1230 fib_proc_exit(net); in fib_net_exit()
1231 nl_fib_lookup_exit(net); in fib_net_exit()
1232 ip_fib_net_exit(net); in fib_net_exit()