netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@idosch.org,
	roopa@cumulusnetworks.com, eric.dumazet@gmail.com,
	weiwan@google.com, kafai@fb.com, yoshfuji@linux-ipv6.org,
	David Ahern <dsahern@gmail.com>
Subject: [PATCH RFC net-next 13/20] net/ipv6: Move dst flags to booleans in fib entries
Date: Sun, 25 Feb 2018 11:47:23 -0800	[thread overview]
Message-ID: <20180225194730.30063-14-dsahern@gmail.com> (raw)
In-Reply-To: <20180225194730.30063-1-dsahern@gmail.com>

Use bool to hold requests for certain dst settings when a FIB entry
is converted to a dst.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/net/ip6_fib.h |  5 ++++-
 net/ipv6/addrconf.c   |  4 ++--
 net/ipv6/route.c      | 29 ++++++++++++++++++++++++-----
 3 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 3ba0bb7c7a43..d867b1696927 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -177,7 +177,10 @@ struct rt6_info {
 	u8				fib6_type;
 	u8				exception_bucket_flushed:1,
 					should_flush:1,
-					unused:6;
+					dst_nocount:1,
+					dst_nopolicy:1,
+					dst_host:1,
+					unused:3;
 
 	unsigned long			expires;
 	struct dst_metrics		*fib6_metrics;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 478f45bf13cf..6ac54498ae71 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1058,7 +1058,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
 
 	if (net->ipv6.devconf_all->disable_policy ||
 	    idev->cnf.disable_policy)
-		rt->dst.flags |= DST_NOPOLICY;
+		rt->dst_nopolicy = true;
 
 	neigh_parms_data_state_setall(idev->nd_parms);
 
@@ -5945,7 +5945,7 @@ void addrconf_disable_policy_idev(struct inet6_dev *idev, int val)
 			int cpu;
 
 			rcu_read_lock();
-			addrconf_set_nopolicy(ifa->rt, val);
+			ifa->rt->dst_nopolicy = val ? true : false;
 			if (rt->rt6i_pcpu) {
 				for_each_possible_cpu(cpu) {
 					struct rt6_info **rtp;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 066203d2f9d3..61f4f0333c73 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -935,6 +935,20 @@ static int ip6_rt_type_to_error(u8 fib6_type)
 	return fib6_prop[fib6_type];
 }
 
+static unsigned short fib6_info_dst_flags(struct rt6_info *rt)
+{
+	unsigned short flags = 0;
+
+	if (rt->dst_nocount)
+		flags |= DST_NOCOUNT;
+	if (rt->dst_nopolicy)
+		flags |= DST_NOPOLICY;
+	if (rt->dst_host)
+		flags |= DST_HOST;
+
+	return flags;
+}
+
 static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct rt6_info *ort)
 {
 	rt->dst.error = ip6_rt_type_to_error(ort->fib6_type);
@@ -959,6 +973,8 @@ static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct rt6_info *ort)
 
 static void ip6_rt_init_dst(struct rt6_info *rt, struct rt6_info *ort)
 {
+	rt->dst.flags |= fib6_info_dst_flags(ort);
+
 	if (ort->rt6i_flags & RTF_REJECT) {
 		ip6_rt_init_dst_reject(rt, ort);
 		return;
@@ -968,7 +984,6 @@ static void ip6_rt_init_dst(struct rt6_info *rt, struct rt6_info *ort)
 	rt->dst.output = ip6_output;
 
 	if (ort->fib6_type == RTN_LOCAL) {
-		rt->dst.flags |= DST_HOST;
 		rt->dst.input = ip6_input;
 	} else if (ipv6_addr_type(&ort->rt6i_dst.addr) & IPV6_ADDR_MULTICAST) {
 		rt->dst.input = ip6_mc_input;
@@ -1056,11 +1071,12 @@ static bool ip6_hold_safe(struct net *net, struct rt6_info **prt,
 /* called with rcu_lock held */
 static struct rt6_info *ip6_create_rt_rcu(struct rt6_info *rt)
 {
+	unsigned short flags = fib6_info_dst_flags(rt);
 	struct net_device *dev;
 	struct rt6_info *nrt;
 
 	dev = ip6_rt_get_dev_rcu(rt);
-	nrt = __ip6_dst_alloc(dev_net(dev), dev, 0);
+	nrt = __ip6_dst_alloc(dev_net(dev), dev, flags);
 	if (nrt)
 		ip6_rt_copy_init(nrt, rt);
 
@@ -1215,12 +1231,13 @@ static struct rt6_info *ip6_rt_cache_alloc(struct rt6_info *ort,
 
 static struct rt6_info *ip6_rt_pcpu_alloc(struct rt6_info *rt)
 {
+	unsigned short flags = fib6_info_dst_flags(rt);
 	struct net_device *dev;
 	struct rt6_info *pcpu_rt;
 
 	rcu_read_lock();
 	dev = ip6_rt_get_dev_rcu(rt);
-	pcpu_rt = __ip6_dst_alloc(dev_net(dev), dev, rt->dst.flags);
+	pcpu_rt = __ip6_dst_alloc(dev_net(dev), dev, flags);
 	rcu_read_unlock();
 	if (!pcpu_rt)
 		return NULL;
@@ -2768,7 +2785,7 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
 	ipv6_addr_prefix(&rt->rt6i_dst.addr, &cfg->fc_dst, cfg->fc_dst_len);
 	rt->rt6i_dst.plen = cfg->fc_dst_len;
 	if (rt->rt6i_dst.plen == 128)
-		rt->dst.flags |= DST_HOST;
+		rt->dst_host = true;
 
 #ifdef CONFIG_IPV6_SUBTREES
 	ipv6_addr_prefix(&rt->rt6i_src.addr, &cfg->fc_src, cfg->fc_src_len);
@@ -3474,10 +3491,12 @@ struct rt6_info *addrconf_dst_alloc(struct net *net,
 	if (!rt)
 		return ERR_PTR(-ENOMEM);
 
+	rt->dst_nocount = true;
+
 	in6_dev_hold(idev);
 	rt->rt6i_idev = idev;
 
-	rt->dst.flags |= DST_HOST;
+	rt->dst_host = true;
 	rt->rt6i_protocol = RTPROT_KERNEL;
 	rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
 	if (anycast) {
-- 
2.11.0

  parent reply	other threads:[~2018-02-25 19:47 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-25 19:47 [PATCH RFC net-next 00/20] net/ipv6: Separate data structures for FIB and data path David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 01/20] net: Move fib_convert_metrics to dst core David Ahern
2018-02-26 19:05   ` David Miller
2018-02-26 20:07     ` David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 02/20] vrf: Move fib6_table into net_vrf David Ahern
2018-02-26 19:08   ` David Miller
2018-02-26 20:13     ` David Ahern
2018-02-26 20:34       ` David Miller
2018-02-25 19:47 ` [PATCH RFC net-next 03/20] net/ipv6: Pass net to fib6_update_sernum David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 04/20] net/ipv6: Pass net namespace to route functions David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 05/20] net/ipv6: Move support functions up in route.c David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 06/20] net/ipv6: Save route type in rt6_info flags David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 07/20] net/ipv6: Move nexthop data to fib6_nh David Ahern
2018-02-26 22:28   ` Wei Wang
2018-02-26 22:47     ` David Ahern
2018-02-26 23:05       ` Wei Wang
2018-02-25 19:47 ` [PATCH RFC net-next 08/20] net/ipv6: Defer initialization of dst to data path David Ahern
2018-02-26 19:17   ` David Miller
2018-02-26 20:20     ` David Ahern
2018-02-26 20:22       ` David Miller
2018-02-25 19:47 ` [PATCH RFC net-next 09/20] net/ipv6: move metrics from dst to rt6_info David Ahern
2018-02-27  0:01   ` [net/ipv6] 15c9251fd2: BUG:unable_to_handle_kernel kernel test robot
2018-02-25 19:47 ` [PATCH RFC net-next 10/20] net/ipv6: move expires into rt6_info David Ahern
2018-02-26 22:28   ` Wei Wang
2018-02-26 22:55     ` David Ahern
2018-02-27  0:31       ` Wei Wang
2018-02-28 19:21       ` Martin KaFai Lau
2018-02-28 22:25         ` David Ahern
2018-02-28 22:56           ` Martin KaFai Lau
2018-02-25 19:47 ` [PATCH RFC net-next 11/20] net/ipv6: Add fib6_null_entry David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 12/20] net/ipv6: Add rt6_info create function for ip6_pol_route_lookup David Ahern
2018-02-25 19:47 ` David Ahern [this message]
2018-02-25 19:47 ` [PATCH RFC net-next 14/20] net/ipv6: Create a neigh_lookup for FIB entries David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 15/20] net/ipv6: Add gfp_flags to route add functions David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 16/20] net/ipv6: Cleanup exception route handling David Ahern
2018-02-26 19:27   ` David Miller
2018-02-26 20:25     ` David Ahern
2018-02-26 20:29       ` David Miller
2018-02-26 22:29   ` Wei Wang
2018-02-26 23:02     ` David Ahern
2018-02-27  0:32       ` Wei Wang
2018-02-25 19:47 ` [PATCH RFC net-next 17/20] net/ipv6: introduce fib6_info struct and helpers David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 18/20] net/ipv6: separate handling of FIB entries from dst based routes David Ahern
2018-02-28 18:44   ` Martin KaFai Lau
2018-02-28 20:10     ` David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 19/20] net/ipv6: Flip FIB entries to fib6_info David Ahern
2018-02-25 19:47 ` [PATCH RFC net-next 20/20] net/ipv6: Remove unused code and variables for rt6_info David Ahern

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=20180225194730.30063-14-dsahern@gmail.com \
    --to=dsahern@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=idosch@idosch.org \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.com \
    --cc=weiwan@google.com \
    --cc=yoshfuji@linux-ipv6.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).