Commit 1e48aac1 authored by David S. Miller's avatar David S. Miller

Merge branch 'ipv6-simplify-rt6_fill_node'

David Ahern says:

====================
net: ipv6: simplify rt6_fill_node

Remove a couple of unnecessary input arguments to rt6_fill_node.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1ce463dd f8cfe2ce
...@@ -116,7 +116,7 @@ struct mfc6_cache { ...@@ -116,7 +116,7 @@ struct mfc6_cache {
struct rtmsg; struct rtmsg;
extern int ip6mr_get_route(struct net *net, struct sk_buff *skb, extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
struct rtmsg *rtm, int nowait, u32 portid); struct rtmsg *rtm, u32 portid);
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb); extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);
......
...@@ -2288,7 +2288,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb, ...@@ -2288,7 +2288,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
} }
int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
int nowait, u32 portid) u32 portid)
{ {
int err; int err;
struct mr6_table *mrt; struct mr6_table *mrt;
...@@ -2315,11 +2315,6 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, ...@@ -2315,11 +2315,6 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
struct net_device *dev; struct net_device *dev;
int vif; int vif;
if (nowait) {
read_unlock(&mrt_lock);
return -EAGAIN;
}
dev = skb->dev; dev = skb->dev;
if (!dev || (vif = ip6mr_find_vif(mrt, dev)) < 0) { if (!dev || (vif = ip6mr_find_vif(mrt, dev)) < 0) {
read_unlock(&mrt_lock); read_unlock(&mrt_lock);
...@@ -2357,7 +2352,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm, ...@@ -2357,7 +2352,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
return err; return err;
} }
if (!nowait && (rtm->rtm_flags&RTM_F_NOTIFY)) if (rtm->rtm_flags & RTM_F_NOTIFY)
cache->mfc_flags |= MFC_NOTIFY; cache->mfc_flags |= MFC_NOTIFY;
err = __ip6mr_fill_mroute(mrt, skb, cache, rtm); err = __ip6mr_fill_mroute(mrt, skb, cache, rtm);
......
...@@ -3169,7 +3169,7 @@ static int rt6_fill_node(struct net *net, ...@@ -3169,7 +3169,7 @@ static int rt6_fill_node(struct net *net,
struct sk_buff *skb, struct rt6_info *rt, struct sk_buff *skb, struct rt6_info *rt,
struct in6_addr *dst, struct in6_addr *src, struct in6_addr *dst, struct in6_addr *src,
int iif, int type, u32 portid, u32 seq, int iif, int type, u32 portid, u32 seq,
int prefix, int nowait, unsigned int flags) unsigned int flags)
{ {
u32 metrics[RTAX_MAX]; u32 metrics[RTAX_MAX];
struct rtmsg *rtm; struct rtmsg *rtm;
...@@ -3177,13 +3177,6 @@ static int rt6_fill_node(struct net *net, ...@@ -3177,13 +3177,6 @@ static int rt6_fill_node(struct net *net,
long expires; long expires;
u32 table; u32 table;
if (prefix) { /* user wants prefix routes only */
if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
/* success since this is not a prefix route */
return 1;
}
}
nlh = nlmsg_put(skb, portid, seq, type, sizeof(*rtm), flags); nlh = nlmsg_put(skb, portid, seq, type, sizeof(*rtm), flags);
if (!nlh) if (!nlh)
return -EMSGSIZE; return -EMSGSIZE;
...@@ -3261,19 +3254,12 @@ static int rt6_fill_node(struct net *net, ...@@ -3261,19 +3254,12 @@ static int rt6_fill_node(struct net *net,
if (iif) { if (iif) {
#ifdef CONFIG_IPV6_MROUTE #ifdef CONFIG_IPV6_MROUTE
if (ipv6_addr_is_multicast(&rt->rt6i_dst.addr)) { if (ipv6_addr_is_multicast(&rt->rt6i_dst.addr)) {
int err = ip6mr_get_route(net, skb, rtm, nowait, int err = ip6mr_get_route(net, skb, rtm, portid);
portid);
if (err == 0)
if (err <= 0) { return 0;
if (!nowait) { if (err < 0)
if (err == 0) goto nla_put_failure;
return 0;
goto nla_put_failure;
} else {
if (err == -EMSGSIZE)
goto nla_put_failure;
}
}
} else } else
#endif #endif
if (nla_put_u32(skb, RTA_IIF, iif)) if (nla_put_u32(skb, RTA_IIF, iif))
...@@ -3331,18 +3317,22 @@ static int rt6_fill_node(struct net *net, ...@@ -3331,18 +3317,22 @@ static int rt6_fill_node(struct net *net,
int rt6_dump_route(struct rt6_info *rt, void *p_arg) int rt6_dump_route(struct rt6_info *rt, void *p_arg)
{ {
struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg; struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
int prefix;
if (nlmsg_len(arg->cb->nlh) >= sizeof(struct rtmsg)) { if (nlmsg_len(arg->cb->nlh) >= sizeof(struct rtmsg)) {
struct rtmsg *rtm = nlmsg_data(arg->cb->nlh); struct rtmsg *rtm = nlmsg_data(arg->cb->nlh);
prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
} else /* user wants prefix routes only */
prefix = 0; if (rtm->rtm_flags & RTM_F_PREFIX &&
!(rt->rt6i_flags & RTF_PREFIX_RT)) {
/* success since this is not a prefix route */
return 1;
}
}
return rt6_fill_node(arg->net, return rt6_fill_node(arg->net,
arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE, arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
NETLINK_CB(arg->cb->skb).portid, arg->cb->nlh->nlmsg_seq, NETLINK_CB(arg->cb->skb).portid, arg->cb->nlh->nlmsg_seq,
prefix, 0, NLM_F_MULTI); NLM_F_MULTI);
} }
static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh) static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
...@@ -3433,7 +3423,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh) ...@@ -3433,7 +3423,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif, err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif,
RTM_NEWROUTE, NETLINK_CB(in_skb).portid, RTM_NEWROUTE, NETLINK_CB(in_skb).portid,
nlh->nlmsg_seq, 0, 0, 0); nlh->nlmsg_seq, 0);
if (err < 0) { if (err < 0) {
kfree_skb(skb); kfree_skb(skb);
goto errout; goto errout;
...@@ -3460,7 +3450,7 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info, ...@@ -3460,7 +3450,7 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info,
goto errout; goto errout;
err = rt6_fill_node(net, skb, rt, NULL, NULL, 0, err = rt6_fill_node(net, skb, rt, NULL, NULL, 0,
event, info->portid, seq, 0, 0, nlm_flags); event, info->portid, seq, nlm_flags);
if (err < 0) { if (err < 0) {
/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
WARN_ON(err == -EMSGSIZE); WARN_ON(err == -EMSGSIZE);
......
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