Lines Matching refs:net
53 static int __net_init fib4_rules_init(struct net *net) in fib4_rules_init() argument
66 &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX]); in fib4_rules_init()
68 &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX]); in fib4_rules_init()
77 struct fib_table *fib_new_table(struct net *net, u32 id) in fib_new_table() argument
84 tb = fib_get_table(net, id); in fib_new_table()
89 alias = fib_new_table(net, RT_TABLE_MAIN); in fib_new_table()
97 rcu_assign_pointer(net->ipv4.fib_local, tb); in fib_new_table()
100 rcu_assign_pointer(net->ipv4.fib_main, tb); in fib_new_table()
103 rcu_assign_pointer(net->ipv4.fib_default, tb); in fib_new_table()
110 hlist_add_head_rcu(&tb->tb_hlist, &net->ipv4.fib_table_hash[h]); in fib_new_table()
115 struct fib_table *fib_get_table(struct net *net, u32 id) in fib_get_table() argument
125 head = &net->ipv4.fib_table_hash[h]; in fib_get_table()
134 static void fib_replace_table(struct net *net, struct fib_table *old, in fib_replace_table() argument
140 rcu_assign_pointer(net->ipv4.fib_local, new); in fib_replace_table()
143 rcu_assign_pointer(net->ipv4.fib_main, new); in fib_replace_table()
146 rcu_assign_pointer(net->ipv4.fib_default, new); in fib_replace_table()
157 int fib_unmerge(struct net *net) in fib_unmerge() argument
162 old = fib_get_table(net, RT_TABLE_LOCAL); in fib_unmerge()
172 fib_replace_table(net, old, new); in fib_unmerge()
179 static void fib_flush(struct net *net) in fib_flush() argument
185 struct hlist_head *head = &net->ipv4.fib_table_hash[h]; in fib_flush()
194 rt_cache_flush(net); in fib_flush()
197 void fib_flush_external(struct net *net) in fib_flush_external() argument
204 head = &net->ipv4.fib_table_hash[h]; in fib_flush_external()
214 static inline unsigned int __inet_dev_addr_type(struct net *net, in __inet_dev_addr_type() argument
230 table = fib_get_table(net, tb_id); in __inet_dev_addr_type()
243 unsigned int inet_addr_type_table(struct net *net, __be32 addr, u32 tb_id) in inet_addr_type_table() argument
245 return __inet_dev_addr_type(net, NULL, addr, tb_id); in inet_addr_type_table()
249 unsigned int inet_addr_type(struct net *net, __be32 addr) in inet_addr_type() argument
251 return __inet_dev_addr_type(net, NULL, addr, RT_TABLE_LOCAL); in inet_addr_type()
255 unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev, in inet_dev_addr_type() argument
260 return __inet_dev_addr_type(net, dev, addr, rt_table); in inet_dev_addr_type()
267 unsigned int inet_addr_type_dev_table(struct net *net, in inet_addr_type_dev_table() argument
273 return __inet_dev_addr_type(net, NULL, addr, rt_table); in inet_addr_type_dev_table()
283 struct net *net; in fib_compute_spec_dst() local
294 net = dev_net(dev); in fib_compute_spec_dst()
305 if (!fib_lookup(net, &fl4, &res, 0)) in fib_compute_spec_dst()
306 return FIB_RES_PREFSRC(net, res); in fib_compute_spec_dst()
329 struct net *net; in __fib_validate_source() local
349 net = dev_net(dev); in __fib_validate_source()
350 if (fib_lookup(net, &fl4, &res, 0)) in __fib_validate_source()
388 if (fib_lookup(net, &fl4, &res, FIB_LOOKUP_IGNORE_LINKSTATE) == 0) { in __fib_validate_source()
439 static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, in rtentry_to_fib_config() argument
446 cfg->fc_nlinfo.nl_net = net; in rtentry_to_fib_config()
507 dev = __dev_get_by_name(net, devname); in rtentry_to_fib_config()
531 addr_type = inet_addr_type_table(net, addr, cfg->fc_table); in rtentry_to_fib_config()
574 int ip_rt_ioctl(struct net *net, unsigned int cmd, void __user *arg) in ip_rt_ioctl() argument
583 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) in ip_rt_ioctl()
590 err = rtentry_to_fib_config(net, cmd, &rt, &cfg); in ip_rt_ioctl()
595 tb = fib_get_table(net, cfg.fc_table); in ip_rt_ioctl()
601 tb = fib_new_table(net, cfg.fc_table); in ip_rt_ioctl()
632 static int rtm_to_fib_config(struct net *net, struct sk_buff *skb, in rtm_to_fib_config() argument
657 cfg->fc_nlinfo.nl_net = net; in rtm_to_fib_config()
711 struct net *net = sock_net(skb->sk); in inet_rtm_delroute() local
716 err = rtm_to_fib_config(net, skb, nlh, &cfg); in inet_rtm_delroute()
720 tb = fib_get_table(net, cfg.fc_table); in inet_rtm_delroute()
733 struct net *net = sock_net(skb->sk); in inet_rtm_newroute() local
738 err = rtm_to_fib_config(net, skb, nlh, &cfg); in inet_rtm_newroute()
742 tb = fib_new_table(net, cfg.fc_table); in inet_rtm_newroute()
755 struct net *net = sock_net(skb->sk); in inet_dump_fib() local
773 head = &net->ipv4.fib_table_hash[h]; in inet_dump_fib()
804 struct net *net = dev_net(ifa->ifa_dev->dev); in fib_magic() local
816 .nl_net = net, in fib_magic()
823 tb = fib_new_table(net, tb_id); in fib_magic()
1039 static void nl_fib_lookup(struct net *net, struct fib_result_nl *frn) in nl_fib_lookup() argument
1053 tb = fib_get_table(net, frn->tb_id_in); in nl_fib_lookup()
1076 struct net *net; in nl_fib_input() local
1081 net = sock_net(skb->sk); in nl_fib_input()
1093 nl_fib_lookup(net, frn); in nl_fib_input()
1098 netlink_unicast(net->ipv4.fibnl, skb, portid, MSG_DONTWAIT); in nl_fib_input()
1101 static int __net_init nl_fib_lookup_init(struct net *net) in nl_fib_lookup_init() argument
1108 sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, &cfg); in nl_fib_lookup_init()
1111 net->ipv4.fibnl = sk; in nl_fib_lookup_init()
1115 static void nl_fib_lookup_exit(struct net *net) in nl_fib_lookup_exit() argument
1117 netlink_kernel_release(net->ipv4.fibnl); in nl_fib_lookup_exit()
1118 net->ipv4.fibnl = NULL; in nl_fib_lookup_exit()
1134 struct net *net = dev_net(dev); in fib_inetaddr_event() local
1142 atomic_inc(&net->ipv4.dev_addr_genid); in fib_inetaddr_event()
1147 atomic_inc(&net->ipv4.dev_addr_genid); in fib_inetaddr_event()
1166 struct net *net = dev_net(dev); in fib_netdev_event() local
1187 atomic_inc(&net->ipv4.dev_addr_genid); in fib_netdev_event()
1188 rt_cache_flush(net); in fib_netdev_event()
1201 rt_cache_flush(net); in fib_netdev_event()
1223 static int __net_init ip_fib_net_init(struct net *net) in ip_fib_net_init() argument
1231 net->ipv4.fib_table_hash = kzalloc(size, GFP_KERNEL); in ip_fib_net_init()
1232 if (!net->ipv4.fib_table_hash) in ip_fib_net_init()
1235 err = fib4_rules_init(net); in ip_fib_net_init()
1241 kfree(net->ipv4.fib_table_hash); in ip_fib_net_init()
1245 static void ip_fib_net_exit(struct net *net) in ip_fib_net_exit() argument
1251 RCU_INIT_POINTER(net->ipv4.fib_local, NULL); in ip_fib_net_exit()
1252 RCU_INIT_POINTER(net->ipv4.fib_main, NULL); in ip_fib_net_exit()
1253 RCU_INIT_POINTER(net->ipv4.fib_default, NULL); in ip_fib_net_exit()
1256 struct hlist_head *head = &net->ipv4.fib_table_hash[i]; in ip_fib_net_exit()
1268 fib4_rules_exit(net); in ip_fib_net_exit()
1271 kfree(net->ipv4.fib_table_hash); in ip_fib_net_exit()
1274 static int __net_init fib_net_init(struct net *net) in fib_net_init() argument
1279 net->ipv4.fib_num_tclassid_users = 0; in fib_net_init()
1281 error = ip_fib_net_init(net); in fib_net_init()
1284 error = nl_fib_lookup_init(net); in fib_net_init()
1287 error = fib_proc_init(net); in fib_net_init()
1294 nl_fib_lookup_exit(net); in fib_net_init()
1296 ip_fib_net_exit(net); in fib_net_init()
1300 static void __net_exit fib_net_exit(struct net *net) in fib_net_exit() argument
1302 fib_proc_exit(net); in fib_net_exit()
1303 nl_fib_lookup_exit(net); in fib_net_exit()
1304 ip_fib_net_exit(net); in fib_net_exit()