Commit 40e22e8f authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[IPv6] route: Simplify ip6_ins_rt()

Provide a simple ip6_ins_rt() for the majority of users and
an alternative for the exception via netlink. Avoids code
obfuscation.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e0a1ad73
...@@ -65,10 +65,7 @@ extern int ip6_route_add(struct in6_rtmsg *rtmsg, ...@@ -65,10 +65,7 @@ extern int ip6_route_add(struct in6_rtmsg *rtmsg,
void *rtattr, void *rtattr,
struct netlink_skb_parms *req, struct netlink_skb_parms *req,
u32 table_id); u32 table_id);
extern int ip6_ins_rt(struct rt6_info *, extern int ip6_ins_rt(struct rt6_info *);
struct nlmsghdr *,
void *rtattr,
struct netlink_skb_parms *req);
extern int ip6_del_rt(struct rt6_info *); extern int ip6_del_rt(struct rt6_info *);
extern int ip6_rt_addr_add(struct in6_addr *addr, extern int ip6_rt_addr_add(struct in6_addr *addr,
......
...@@ -3548,7 +3548,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) ...@@ -3548,7 +3548,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
switch (event) { switch (event) {
case RTM_NEWADDR: case RTM_NEWADDR:
ip6_ins_rt(ifp->rt, NULL, NULL, NULL); ip6_ins_rt(ifp->rt);
if (ifp->idev->cnf.forwarding) if (ifp->idev->cnf.forwarding)
addrconf_join_anycast(ifp); addrconf_join_anycast(ifp);
break; break;
......
...@@ -335,7 +335,7 @@ int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr) ...@@ -335,7 +335,7 @@ int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr)
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
dst_hold(&rt->u.dst); dst_hold(&rt->u.dst);
if (ip6_ins_rt(rt, NULL, NULL, NULL)) if (ip6_ins_rt(rt))
dst_release(&rt->u.dst); dst_release(&rt->u.dst);
addrconf_join_solict(dev, &aca->aca_addr); addrconf_join_solict(dev, &aca->aca_addr);
......
...@@ -546,8 +546,8 @@ struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr, ...@@ -546,8 +546,8 @@ struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr,
be destroyed. be destroyed.
*/ */
int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh, static int __ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh,
void *_rtattr, struct netlink_skb_parms *req) void *_rtattr, struct netlink_skb_parms *req)
{ {
int err; int err;
struct fib6_table *table; struct fib6_table *table;
...@@ -560,6 +560,11 @@ int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh, ...@@ -560,6 +560,11 @@ int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh,
return err; return err;
} }
int ip6_ins_rt(struct rt6_info *rt)
{
return __ip6_ins_rt(rt, NULL, NULL, NULL);
}
static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *daddr, static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *daddr,
struct in6_addr *saddr) struct in6_addr *saddr)
{ {
...@@ -657,7 +662,7 @@ restart: ...@@ -657,7 +662,7 @@ restart:
dst_hold(&rt->u.dst); dst_hold(&rt->u.dst);
if (nrt) { if (nrt) {
err = ip6_ins_rt(nrt, NULL, NULL, NULL); err = ip6_ins_rt(nrt);
if (!err) if (!err)
goto out2; goto out2;
} }
...@@ -752,7 +757,7 @@ restart: ...@@ -752,7 +757,7 @@ restart:
dst_hold(&rt->u.dst); dst_hold(&rt->u.dst);
if (nrt) { if (nrt) {
err = ip6_ins_rt(nrt, NULL, NULL, NULL); err = ip6_ins_rt(nrt);
if (!err) if (!err)
goto out2; goto out2;
} }
...@@ -1206,7 +1211,7 @@ install_route: ...@@ -1206,7 +1211,7 @@ install_route:
rt->u.dst.dev = dev; rt->u.dst.dev = dev;
rt->rt6i_idev = idev; rt->rt6i_idev = idev;
rt->rt6i_table = table; rt->rt6i_table = table;
return ip6_ins_rt(rt, nlh, _rtattr, req); return __ip6_ins_rt(rt, nlh, _rtattr, req);
out: out:
if (dev) if (dev)
...@@ -1393,7 +1398,7 @@ restart: ...@@ -1393,7 +1398,7 @@ restart:
nrt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev); nrt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev);
nrt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&nrt->u.dst)); nrt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&nrt->u.dst));
if (ip6_ins_rt(nrt, NULL, NULL, NULL)) if (ip6_ins_rt(nrt))
goto out; goto out;
netevent.old = &rt->u.dst; netevent.old = &rt->u.dst;
...@@ -1483,7 +1488,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, ...@@ -1483,7 +1488,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr,
dst_set_expires(&nrt->u.dst, ip6_rt_mtu_expires); dst_set_expires(&nrt->u.dst, ip6_rt_mtu_expires);
nrt->rt6i_flags |= RTF_DYNAMIC|RTF_EXPIRES; nrt->rt6i_flags |= RTF_DYNAMIC|RTF_EXPIRES;
ip6_ins_rt(nrt, NULL, NULL, NULL); ip6_ins_rt(nrt);
} }
out: out:
dst_release(&rt->u.dst); dst_release(&rt->u.dst);
......
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