Commit 28b18b39 authored by David S. Miller's avatar David S. Miller

Merge branch 'ipv6-Change-addrconf_f6i_alloc-to-use-ip6_route_info_create'

David Ahern says:

====================
ipv6: Change addrconf_f6i_alloc to use ip6_route_info_create

addrconf_f6i_alloc is the last caller of fib6_info_alloc besides
ip6_route_info_create. There really is no good reason for it do
its own fib6_info initialization, so convert it to call
ip6_route_info_create.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a88c26f6 c7a1ce39
...@@ -50,7 +50,8 @@ struct fib6_config { ...@@ -50,7 +50,8 @@ struct fib6_config {
u32 fc_protocol; u32 fc_protocol;
u16 fc_type; /* only 8 bits are used */ u16 fc_type; /* only 8 bits are used */
u16 fc_delete_all_nh : 1, u16 fc_delete_all_nh : 1,
__unused : 15; fc_ignore_dev_down:1,
__unused : 14;
struct in6_addr fc_dst; struct in6_addr fc_dst;
struct in6_addr fc_src; struct in6_addr fc_src;
......
...@@ -2951,9 +2951,6 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, ...@@ -2951,9 +2951,6 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
goto out; goto out;
} }
if (cfg->fc_metric == 0)
cfg->fc_metric = IP6_RT_PRIO_USER;
if (cfg->fc_flags & RTNH_F_ONLINK) { if (cfg->fc_flags & RTNH_F_ONLINK) {
if (!dev) { if (!dev) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
...@@ -3082,7 +3079,7 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, ...@@ -3082,7 +3079,7 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
goto out; goto out;
} }
if (!(dev->flags & IFF_UP)) { if (!(dev->flags & IFF_UP) && !cfg->fc_ignore_dev_down) {
NL_SET_ERR_MSG(extack, "Nexthop device is not up"); NL_SET_ERR_MSG(extack, "Nexthop device is not up");
err = -ENETDOWN; err = -ENETDOWN;
goto out; goto out;
...@@ -3604,7 +3601,7 @@ static void rtmsg_to_fib6_config(struct net *net, ...@@ -3604,7 +3601,7 @@ static void rtmsg_to_fib6_config(struct net *net,
.fc_table = l3mdev_fib_table_by_index(net, rtmsg->rtmsg_ifindex) ? .fc_table = l3mdev_fib_table_by_index(net, rtmsg->rtmsg_ifindex) ?
: RT6_TABLE_MAIN, : RT6_TABLE_MAIN,
.fc_ifindex = rtmsg->rtmsg_ifindex, .fc_ifindex = rtmsg->rtmsg_ifindex,
.fc_metric = rtmsg->rtmsg_metric, .fc_metric = rtmsg->rtmsg_metric ? : IP6_RT_PRIO_USER,
.fc_expires = rtmsg->rtmsg_info, .fc_expires = rtmsg->rtmsg_info,
.fc_dst_len = rtmsg->rtmsg_dst_len, .fc_dst_len = rtmsg->rtmsg_dst_len,
.fc_src_len = rtmsg->rtmsg_src_len, .fc_src_len = rtmsg->rtmsg_src_len,
...@@ -3715,36 +3712,26 @@ struct fib6_info *addrconf_f6i_alloc(struct net *net, ...@@ -3715,36 +3712,26 @@ struct fib6_info *addrconf_f6i_alloc(struct net *net,
const struct in6_addr *addr, const struct in6_addr *addr,
bool anycast, gfp_t gfp_flags) bool anycast, gfp_t gfp_flags)
{ {
u32 tb_id; struct fib6_config cfg = {
struct net_device *dev = idev->dev; .fc_table = l3mdev_fib_table(idev->dev) ? : RT6_TABLE_LOCAL,
struct fib6_info *f6i; .fc_ifindex = idev->dev->ifindex,
.fc_flags = RTF_UP | RTF_ADDRCONF | RTF_NONEXTHOP,
f6i = fib6_info_alloc(gfp_flags); .fc_dst = *addr,
if (!f6i) .fc_dst_len = 128,
return ERR_PTR(-ENOMEM); .fc_protocol = RTPROT_KERNEL,
.fc_nlinfo.nl_net = net,
.fc_ignore_dev_down = true,
};
f6i->fib6_metrics = ip_fib_metrics_init(net, NULL, 0, NULL);
f6i->dst_nocount = true;
f6i->dst_host = true;
f6i->fib6_protocol = RTPROT_KERNEL;
f6i->fib6_flags = RTF_UP | RTF_NONEXTHOP;
if (anycast) { if (anycast) {
f6i->fib6_type = RTN_ANYCAST; cfg.fc_type = RTN_ANYCAST;
f6i->fib6_flags |= RTF_ANYCAST; cfg.fc_flags |= RTF_ANYCAST;
} else { } else {
f6i->fib6_type = RTN_LOCAL; cfg.fc_type = RTN_LOCAL;
f6i->fib6_flags |= RTF_LOCAL; cfg.fc_flags |= RTF_LOCAL;
} }
f6i->fib6_nh.nh_gw = *addr; return ip6_route_info_create(&cfg, gfp_flags, NULL);
dev_hold(dev);
f6i->fib6_nh.nh_dev = dev;
f6i->fib6_dst.addr = *addr;
f6i->fib6_dst.plen = 128;
tb_id = l3mdev_fib_table(idev->dev) ? : RT6_TABLE_LOCAL;
f6i->fib6_table = fib6_get_table(net, tb_id);
return f6i;
} }
/* remove deleted ip from prefsrc entries */ /* remove deleted ip from prefsrc entries */
...@@ -4524,6 +4511,9 @@ static int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -4524,6 +4511,9 @@ static int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err < 0) if (err < 0)
return err; return err;
if (cfg.fc_metric == 0)
cfg.fc_metric = IP6_RT_PRIO_USER;
if (cfg.fc_mp) if (cfg.fc_mp)
return ip6_route_multipath_add(&cfg, extack); return ip6_route_multipath_add(&cfg, extack);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment