All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: idosch@mellanox.com, jiri@mellanox.com, saeedm@mellanox.com,
	David Ahern <dsahern@gmail.com>
Subject: [PATCH v3 net-next 09/13] ipv6: Change rt6_add_nexthop and rt6_nexthop_info to take fib6_nh
Date: Wed, 27 Mar 2019 20:53:54 -0700	[thread overview]
Message-ID: <20190328035358.4929-10-dsahern@kernel.org> (raw)
In-Reply-To: <20190328035358.4929-1-dsahern@kernel.org>

From: David Ahern <dsahern@gmail.com>

rt6_add_nexthop and rt6_nexthop_info only need the fib6_info for the
gateway flag and the nexthop weight, and the presence of a gateway is now
per-nexthop. Update the signatures to take a fib6_nh and nexthop weight
and better align with the ipv4 versions.

Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
---
 net/ipv6/route.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 66cbb44cd92e..681c7184e157 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4583,37 +4583,37 @@ static size_t rt6_nlmsg_size(struct fib6_info *rt)
 	       + nexthop_len;
 }
 
-static int rt6_nexthop_info(struct sk_buff *skb, struct fib6_info *rt,
+static int rt6_nexthop_info(struct sk_buff *skb, const struct fib6_nh *fib6_nh,
 			    unsigned int *flags, bool skip_oif)
 {
-	if (rt->fib6_nh.nh_flags & RTNH_F_DEAD)
+	if (fib6_nh->nh_flags & RTNH_F_DEAD)
 		*flags |= RTNH_F_DEAD;
 
-	if (rt->fib6_nh.nh_flags & RTNH_F_LINKDOWN) {
+	if (fib6_nh->nh_flags & RTNH_F_LINKDOWN) {
 		*flags |= RTNH_F_LINKDOWN;
 
 		rcu_read_lock();
-		if (ip6_ignore_linkdown(rt->fib6_nh.nh_dev))
+		if (ip6_ignore_linkdown(fib6_nh->nh_dev))
 			*flags |= RTNH_F_DEAD;
 		rcu_read_unlock();
 	}
 
-	if (rt->fib6_nh.fib_nh_has_gw) {
-		if (nla_put_in6_addr(skb, RTA_GATEWAY, &rt->fib6_nh.nh_gw) < 0)
+	if (fib6_nh->fib_nh_has_gw) {
+		if (nla_put_in6_addr(skb, RTA_GATEWAY, &fib6_nh->nh_gw) < 0)
 			goto nla_put_failure;
 	}
 
-	*flags |= (rt->fib6_nh.nh_flags & RTNH_F_ONLINK);
-	if (rt->fib6_nh.nh_flags & RTNH_F_OFFLOAD)
+	*flags |= (fib6_nh->nh_flags & RTNH_F_ONLINK);
+	if (fib6_nh->nh_flags & RTNH_F_OFFLOAD)
 		*flags |= RTNH_F_OFFLOAD;
 
 	/* not needed for multipath encoding b/c it has a rtnexthop struct */
-	if (!skip_oif && rt->fib6_nh.nh_dev &&
-	    nla_put_u32(skb, RTA_OIF, rt->fib6_nh.nh_dev->ifindex))
+	if (!skip_oif && fib6_nh->nh_dev &&
+	    nla_put_u32(skb, RTA_OIF, fib6_nh->nh_dev->ifindex))
 		goto nla_put_failure;
 
-	if (rt->fib6_nh.nh_lwtstate &&
-	    lwtunnel_fill_encap(skb, rt->fib6_nh.nh_lwtstate) < 0)
+	if (fib6_nh->nh_lwtstate &&
+	    lwtunnel_fill_encap(skb, fib6_nh->nh_lwtstate) < 0)
 		goto nla_put_failure;
 
 	return 0;
@@ -4623,9 +4623,9 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct fib6_info *rt,
 }
 
 /* add multipath next hop */
-static int rt6_add_nexthop(struct sk_buff *skb, struct fib6_info *rt)
+static int rt6_add_nexthop(struct sk_buff *skb, const struct fib6_nh *fib6_nh)
 {
-	const struct net_device *dev = rt->fib6_nh.nh_dev;
+	const struct net_device *dev = fib6_nh->nh_dev;
 	struct rtnexthop *rtnh;
 	unsigned int flags = 0;
 
@@ -4633,10 +4633,10 @@ static int rt6_add_nexthop(struct sk_buff *skb, struct fib6_info *rt)
 	if (!rtnh)
 		goto nla_put_failure;
 
-	rtnh->rtnh_hops = rt->fib6_nh.nh_weight - 1;
+	rtnh->rtnh_hops = fib6_nh->nh_weight - 1;
 	rtnh->rtnh_ifindex = dev ? dev->ifindex : 0;
 
-	if (rt6_nexthop_info(skb, rt, &flags, true) < 0)
+	if (rt6_nexthop_info(skb, fib6_nh, &flags, true) < 0)
 		goto nla_put_failure;
 
 	rtnh->rtnh_flags = flags;
@@ -4766,18 +4766,19 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 		if (!mp)
 			goto nla_put_failure;
 
-		if (rt6_add_nexthop(skb, rt) < 0)
+		if (rt6_add_nexthop(skb, &rt->fib6_nh) < 0)
 			goto nla_put_failure;
 
 		list_for_each_entry_safe(sibling, next_sibling,
 					 &rt->fib6_siblings, fib6_siblings) {
-			if (rt6_add_nexthop(skb, sibling) < 0)
+			if (rt6_add_nexthop(skb, &sibling->fib6_nh) < 0)
 				goto nla_put_failure;
 		}
 
 		nla_nest_end(skb, mp);
 	} else {
-		if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags, false) < 0)
+		if (rt6_nexthop_info(skb, &rt->fib6_nh, &rtm->rtm_flags,
+				     false) < 0)
 			goto nla_put_failure;
 	}
 
-- 
2.11.0


  parent reply	other threads:[~2019-03-28  3:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28  3:53 [PATCH v3 net-next 00/13] net: Move fib_nh and fib6_nh to a common struct David Ahern
2019-03-28  3:53 ` [PATCH v3 net-next 01/13] ipv4: Define fib_get_nhs when CONFIG_IP_ROUTE_MULTIPATH is disabled David Ahern
2019-03-28  3:53 ` [PATCH v3 net-next 02/13] ipv4: Move IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN to helper David Ahern
2019-03-28  3:53 ` [PATCH v3 net-next 03/13] ipv4: Create init helper for fib_nh David Ahern
2019-03-28  8:34   ` Ido Schimmel
2019-03-28  3:53 ` [PATCH v3 net-next 04/13] ipv4: Create cleanup " David Ahern
2019-03-28  3:53 ` [PATCH v3 net-next 05/13] ipv6: Create init helper for fib6_nh David Ahern
2019-03-28 11:17   ` Ido Schimmel
2019-03-28  3:53 ` [PATCH v3 net-next 06/13] ipv6: Create cleanup " David Ahern
2019-03-28 11:18   ` Ido Schimmel
2019-03-28  3:53 ` [PATCH v3 net-next 07/13] ipv6: Move gateway checks to a fib6_nh setting David Ahern
2019-03-28 11:20   ` Ido Schimmel
2019-03-28  3:53 ` [PATCH v3 net-next 08/13] ipv6: Refactor fib6_ignore_linkdown David Ahern
2019-03-28  3:53 ` David Ahern [this message]
2019-03-28  3:53 ` [PATCH v3 net-next 10/13] ipv4: Rename fib_nh entries David Ahern
2019-03-28  3:53 ` [PATCH v3 net-next 11/13] ipv6: Rename fib6_nh entries David Ahern
2019-03-28  3:53 ` [PATCH v3 net-next 12/13] net: Add fib_nh_common and update fib_nh and fib6_nh David Ahern
2019-03-28 11:22   ` Ido Schimmel
2019-03-28  3:53 ` [PATCH v3 net-next 13/13] net: Use common nexthop init and release helpers David Ahern
2019-03-28 11:23   ` Ido Schimmel
2019-03-28 15:50   ` Alexei Starovoitov
2019-03-28 18:10     ` David Ahern
2019-03-29 17:53 ` [PATCH v3 net-next 00/13] net: Move fib_nh and fib6_nh to a common struct David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190328035358.4929-10-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.