netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] net: dst: add and use dst_flags_t
@ 2017-12-06 21:35 Alexey Dobriyan
  2017-12-06 21:35 ` [PATCH 2/3] net: dst: switch to 8-bit dst->flags Alexey Dobriyan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2017-12-06 21:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Alexey Dobriyan

Typedef dst->flags for checking with sparse.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/net/vrf.c       |  2 +-
 include/net/dst.h       | 23 ++++++++++++-----------
 include/net/ip6_route.h |  2 +-
 net/core/dst.c          |  4 ++--
 net/ipv6/route.c        |  4 ++--
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index feb1b2e15c2e..f6a5df216fec 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -493,7 +493,7 @@ static void vrf_rt6_release(struct net_device *dev, struct net_vrf *vrf)
 
 static int vrf_rt6_create(struct net_device *dev)
 {
-	int flags = DST_HOST | DST_NOPOLICY | DST_NOXFRM;
+	dst_flags_t flags = DST_HOST | DST_NOPOLICY | DST_NOXFRM;
 	struct net_vrf *vrf = netdev_priv(dev);
 	struct net *net = dev_net(dev);
 	struct fib6_table *rt6i_table;
diff --git a/include/net/dst.h b/include/net/dst.h
index 33d2a5433924..0f0905bda423 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -31,6 +31,7 @@
  */
 
 struct sk_buff;
+typedef unsigned short __bitwise dst_flags_t;
 
 struct dst_entry {
 	struct net_device       *dev;
@@ -45,15 +46,15 @@ struct dst_entry {
 	int			(*input)(struct sk_buff *);
 	int			(*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
 
-	unsigned short		flags;
-#define DST_HOST		0x0001
-#define DST_NOXFRM		0x0002
-#define DST_NOPOLICY		0x0004
-#define DST_NOCOUNT		0x0008
-#define DST_FAKE_RTABLE		0x0010
-#define DST_XFRM_TUNNEL		0x0020
-#define DST_XFRM_QUEUE		0x0040
-#define DST_METADATA		0x0080
+	dst_flags_t		flags;
+#define DST_HOST		((dst_flags_t __force)0x0001)
+#define DST_NOXFRM		((dst_flags_t __force)0x0002)
+#define DST_NOPOLICY		((dst_flags_t __force)0x0004)
+#define DST_NOCOUNT		((dst_flags_t __force)0x0008)
+#define DST_FAKE_RTABLE		((dst_flags_t __force)0x0010)
+#define DST_XFRM_TUNNEL		((dst_flags_t __force)0x0020)
+#define DST_XFRM_QUEUE		((dst_flags_t __force)0x0040)
+#define DST_METADATA		((dst_flags_t __force)0x0080)
 
 	/* A non-zero value of dst->obsolete forces by-hand validation
 	 * of the route entry.  Positive values are set by the generic
@@ -388,10 +389,10 @@ static inline int dst_discard(struct sk_buff *skb)
 	return dst_discard_out(&init_net, skb->sk, skb);
 }
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev, int initial_ref,
-		int initial_obsolete, unsigned short flags);
+		int initial_obsolete, dst_flags_t flags);
 void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 	      struct net_device *dev, int initial_ref, int initial_obsolete,
-	      unsigned short flags);
+	      dst_flags_t flags);
 struct dst_entry *dst_destroy(struct dst_entry *dst);
 void dst_dev_put(struct dst_entry *dst);
 
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 18e442ea93d8..eec7e7ac564b 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -131,7 +131,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
 				    const struct in6_addr *addr, bool anycast);
 
 struct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev,
-			       int flags);
+			       dst_flags_t flags);
 
 /*
  *	support functions for ND
diff --git a/net/core/dst.c b/net/core/dst.c
index 007aa0b08291..d7cce39c3552 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -61,7 +61,7 @@ const struct dst_metrics dst_default_metrics = {
 
 void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 	      struct net_device *dev, int initial_ref, int initial_obsolete,
-	      unsigned short flags)
+	      dst_flags_t flags)
 {
 	dst->dev = dev;
 	if (dev)
@@ -92,7 +92,7 @@ void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 EXPORT_SYMBOL(dst_init);
 
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev,
-		int initial_ref, int initial_obsolete, unsigned short flags)
+		int initial_ref, int initial_obsolete, dst_flags_t flags)
 {
 	struct dst_entry *dst;
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b3f4d19b3ca5..1d6d53a5d951 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -356,7 +356,7 @@ static void rt6_info_init(struct rt6_info *rt)
 /* allocate dst with ip6_dst_ops */
 static struct rt6_info *__ip6_dst_alloc(struct net *net,
 					struct net_device *dev,
-					int flags)
+					dst_flags_t flags)
 {
 	struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev,
 					1, DST_OBSOLETE_FORCE_CHK, flags);
@@ -371,7 +371,7 @@ static struct rt6_info *__ip6_dst_alloc(struct net *net,
 
 struct rt6_info *ip6_dst_alloc(struct net *net,
 			       struct net_device *dev,
-			       int flags)
+			       dst_flags_t flags)
 {
 	struct rt6_info *rt = __ip6_dst_alloc(net, dev, flags);
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-06 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-06 21:35 [PATCH 1/3] net: dst: add and use dst_flags_t Alexey Dobriyan
2017-12-06 21:35 ` [PATCH 2/3] net: dst: switch to 8-bit dst->flags Alexey Dobriyan
2017-12-06 21:35 ` [PATCH 3/3] net: dst: make dst->obsolete 8-bit Alexey Dobriyan
2017-12-06 21:39 ` [PATCH 1/3] net: dst: add and use dst_flags_t David Miller

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).