route.c (fe4007999599c02598c17b643e8de43e487d48e8) route.c (12d94a804946af291e24b80fc53ec86264765781)
1/*
2 * Linux INET6 implementation
3 * FIB front-end.
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * This program is free software; you can redistribute it and/or

--- 403 unchanged lines hidden (view full) ---

412static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
413 int how)
414{
415 struct rt6_info *rt = (struct rt6_info *)dst;
416 struct inet6_dev *idev = rt->rt6i_idev;
417 struct net_device *loopback_dev =
418 dev_net(dev)->loopback_dev;
419
1/*
2 * Linux INET6 implementation
3 * FIB front-end.
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * This program is free software; you can redistribute it and/or

--- 403 unchanged lines hidden (view full) ---

412static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
413 int how)
414{
415 struct rt6_info *rt = (struct rt6_info *)dst;
416 struct inet6_dev *idev = rt->rt6i_idev;
417 struct net_device *loopback_dev =
418 dev_net(dev)->loopback_dev;
419
420 if (dev != loopback_dev) {
421 if (idev && idev->dev == dev) {
422 struct inet6_dev *loopback_idev =
423 in6_dev_get(loopback_dev);
424 if (loopback_idev) {
425 rt->rt6i_idev = loopback_idev;
426 in6_dev_put(idev);
427 }
420 if (idev && idev->dev != loopback_dev) {
421 struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev);
422 if (loopback_idev) {
423 rt->rt6i_idev = loopback_idev;
424 in6_dev_put(idev);
428 }
429 }
430}
431
432static bool __rt6_check_expired(const struct rt6_info *rt)
433{
434 if (rt->rt6i_flags & RTF_EXPIRES)
435 return time_after(jiffies, rt->dst.expires);

--- 2889 unchanged lines hidden (view full) ---

3325 *flags |= RTNH_F_DEAD;
3326 }
3327
3328 if (rt->rt6i_flags & RTF_GATEWAY) {
3329 if (nla_put_in6_addr(skb, RTA_GATEWAY, &rt->rt6i_gateway) < 0)
3330 goto nla_put_failure;
3331 }
3332
425 }
426 }
427}
428
429static bool __rt6_check_expired(const struct rt6_info *rt)
430{
431 if (rt->rt6i_flags & RTF_EXPIRES)
432 return time_after(jiffies, rt->dst.expires);

--- 2889 unchanged lines hidden (view full) ---

3322 *flags |= RTNH_F_DEAD;
3323 }
3324
3325 if (rt->rt6i_flags & RTF_GATEWAY) {
3326 if (nla_put_in6_addr(skb, RTA_GATEWAY, &rt->rt6i_gateway) < 0)
3327 goto nla_put_failure;
3328 }
3329
3333 if (rt->rt6i_nh_flags & RTNH_F_OFFLOAD)
3334 *flags |= RTNH_F_OFFLOAD;
3335
3336 /* not needed for multipath encoding b/c it has a rtnexthop struct */
3337 if (!skip_oif && rt->dst.dev &&
3338 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
3339 goto nla_put_failure;
3340
3341 if (rt->dst.lwtstate &&
3342 lwtunnel_fill_encap(skb, rt->dst.lwtstate) < 0)
3343 goto nla_put_failure;

--- 378 unchanged lines hidden (view full) ---

3722 net->ipv6.ip6_blk_hole_entry->dst.dev = dev;
3723 net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev);
3724#endif
3725 } else if (event == NETDEV_UNREGISTER &&
3726 dev->reg_state != NETREG_UNREGISTERED) {
3727 /* NETDEV_UNREGISTER could be fired for multiple times by
3728 * netdev_wait_allrefs(). Make sure we only call this once.
3729 */
3330 /* not needed for multipath encoding b/c it has a rtnexthop struct */
3331 if (!skip_oif && rt->dst.dev &&
3332 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
3333 goto nla_put_failure;
3334
3335 if (rt->dst.lwtstate &&
3336 lwtunnel_fill_encap(skb, rt->dst.lwtstate) < 0)
3337 goto nla_put_failure;

--- 378 unchanged lines hidden (view full) ---

3716 net->ipv6.ip6_blk_hole_entry->dst.dev = dev;
3717 net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev);
3718#endif
3719 } else if (event == NETDEV_UNREGISTER &&
3720 dev->reg_state != NETREG_UNREGISTERED) {
3721 /* NETDEV_UNREGISTER could be fired for multiple times by
3722 * netdev_wait_allrefs(). Make sure we only call this once.
3723 */
3730 in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev);
3724 in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev);
3731#ifdef CONFIG_IPV6_MULTIPLE_TABLES
3725#ifdef CONFIG_IPV6_MULTIPLE_TABLES
3732 in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev);
3733 in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev);
3726 in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev);
3727 in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev);
3734#endif
3735 }
3736
3737 return NOTIFY_OK;
3738}
3739
3740/*
3741 * /proc

--- 177 unchanged lines hidden (view full) ---

3919 goto out_ip6_dst_entries;
3920 net->ipv6.ip6_null_entry->dst.path =
3921 (struct dst_entry *)net->ipv6.ip6_null_entry;
3922 net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops;
3923 dst_init_metrics(&net->ipv6.ip6_null_entry->dst,
3924 ip6_template_metrics, true);
3925
3926#ifdef CONFIG_IPV6_MULTIPLE_TABLES
3728#endif
3729 }
3730
3731 return NOTIFY_OK;
3732}
3733
3734/*
3735 * /proc

--- 177 unchanged lines hidden (view full) ---

3913 goto out_ip6_dst_entries;
3914 net->ipv6.ip6_null_entry->dst.path =
3915 (struct dst_entry *)net->ipv6.ip6_null_entry;
3916 net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops;
3917 dst_init_metrics(&net->ipv6.ip6_null_entry->dst,
3918 ip6_template_metrics, true);
3919
3920#ifdef CONFIG_IPV6_MULTIPLE_TABLES
3927 net->ipv6.fib6_has_custom_rules = false;
3928 net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template,
3929 sizeof(*net->ipv6.ip6_prohibit_entry),
3930 GFP_KERNEL);
3931 if (!net->ipv6.ip6_prohibit_entry)
3932 goto out_ip6_null_entry;
3933 net->ipv6.ip6_prohibit_entry->dst.path =
3934 (struct dst_entry *)net->ipv6.ip6_prohibit_entry;
3935 net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops;

--- 159 unchanged lines hidden (view full) ---

4095 if (ret)
4096 goto xfrm6_init;
4097
4098 ret = register_pernet_subsys(&ip6_route_net_late_ops);
4099 if (ret)
4100 goto fib6_rules_init;
4101
4102 ret = -ENOBUFS;
3921 net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template,
3922 sizeof(*net->ipv6.ip6_prohibit_entry),
3923 GFP_KERNEL);
3924 if (!net->ipv6.ip6_prohibit_entry)
3925 goto out_ip6_null_entry;
3926 net->ipv6.ip6_prohibit_entry->dst.path =
3927 (struct dst_entry *)net->ipv6.ip6_prohibit_entry;
3928 net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops;

--- 159 unchanged lines hidden (view full) ---

4088 if (ret)
4089 goto xfrm6_init;
4090
4091 ret = register_pernet_subsys(&ip6_route_net_late_ops);
4092 if (ret)
4093 goto fib6_rules_init;
4094
4095 ret = -ENOBUFS;
4103 if (__rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL, 0) ||
4104 __rtnl_register(PF_INET6, RTM_DELROUTE, inet6_rtm_delroute, NULL, 0) ||
4105 __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL, 0))
4096 if (__rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL, NULL) ||
4097 __rtnl_register(PF_INET6, RTM_DELROUTE, inet6_rtm_delroute, NULL, NULL) ||
4098 __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL, NULL))
4106 goto out_register_late_subsys;
4107
4108 ret = register_netdevice_notifier(&ip6_route_dev_notifier);
4109 if (ret)
4110 goto out_register_late_subsys;
4111
4112 for_each_possible_cpu(cpu) {
4113 struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu);

--- 39 unchanged lines hidden ---
4099 goto out_register_late_subsys;
4100
4101 ret = register_netdevice_notifier(&ip6_route_dev_notifier);
4102 if (ret)
4103 goto out_register_late_subsys;
4104
4105 for_each_possible_cpu(cpu) {
4106 struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu);

--- 39 unchanged lines hidden ---