net: dst: add and use dst_flags_t
Subsystems (4)
PATCH 1/3 net: dst: add and use dst_flags_t
Typedef dst->flags for checking with sparse.
--- 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(-)
drivers/net/vrf.c +1 -1
@@ -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;
include/net/dst.h +12 -11
@@ -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);
include/net/ip6_route.h +1 -1
@@ -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
net/core/dst.c +2 -2
@@ -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;
net/ipv6/route.c +2 -2
@@ -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);
Signature · 1 line
2.13.6
PATCH 2/3 net: dst: switch to 8-bit dst->flags
None of the flags is 16-bit currently.
Space savings on x86_64:
add/remove: 0/0 grow/shrink: 2/16 up/down: 7/-29 (-22)
Function old new delta
netdev_frame_hook 464 470 +6
gre_fill_metadata_dst 257 258 +1
xfrm_resolve_and_create_bundle 2817 2816 -1
ipv6_add_addr 1724 1723 -1
ip6_rt_cache_alloc 472 471 -1
ip6_route_info_create 2955 2954 -1
icmp6_dst_alloc 569 568 -1
dst_init 166 165 -1
dev_fill_metadata_dst 395 394 -1
bnxt_start_xmit 3119 3118 -1
arp_process 2524 2523 -1
addrconf_dst_alloc 442 441 -1
xfrm_lookup 2029 2027 -2
ip6_tnl_xmit 2965 2963 -2
rt_dst_alloc 200 197 -3
do_execute_actions 2799 2796 -3
addrconf_disable_policy_idev 449 445 -4
br_netfilter_rtable_init 66 61 -5
--- include/net/dst.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
include/net/dst.h +10 -9
@@ -31,7 +31,7 @@*/ struct sk_buff ; -typedef unsigned short __bitwise dst_flags_t ; +typedef u8 __bitwise dst_flags_t ;struct dst_entry {struct net_device *dev;
@@ -47,14 +47,15 @@ struct dst_entry {int (*output)(struct net *net,struct sock *sk,struct sk_buff *skb);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) +#define DST_HOST ((dst_flags_t __force)0x01) +#define DST_NOXFRM ((dst_flags_t __force)0x02) +#define DST_NOPOLICY ((dst_flags_t __force)0x04) +#define DST_NOCOUNT ((dst_flags_t __force)0x08) +#define DST_FAKE_RTABLE ((dst_flags_t __force)0x10) +#define DST_XFRM_TUNNEL ((dst_flags_t __force)0x20) +#define DST_XFRM_QUEUE ((dst_flags_t __force)0x40) +#define DST_METADATA ((dst_flags_t __force)0x80) +u8 __pad2;/* A non-zero value of dst->obsolete forces by-hand validation * of the route entry. Positive values are set by the generic
Signature · 1 line
2.13.6
PATCH 3/3 net: dst: make dst->obsolete 8-bit
In reply to Alexey DobriyanAll values are small integers.
Space savings on x86_64:
add/remove: 0/0 grow/shrink: 1/34 up/down: 1/-60 (-59)
Function old new delta
dst_alloc 124 125 +1
xfrm_negative_advice 23 22 -1
xfrm_dst_check 27 26 -1
udp_v6_early_demux 845 844 -1
...
xfrm_resolve_and_create_bundle 2816 2812 -4
dst_dev_put 104 99 -5
xfrm_lookup 2027 2021 -6
update_or_create_fnhe 1339 1329 -10
--- include/net/dst.h | 8 ++++---- net/core/dst.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/dst.h +4 -4
@@ -55,7 +55,6 @@ struct dst_entry {#define DST_XFRM_TUNNEL ((dst_flags_t __force)0x20)#define DST_XFRM_QUEUE ((dst_flags_t __force)0x40)#define DST_METADATA ((dst_flags_t __force)0x80) -u8 __pad2;/* A non-zero value of dst->obsolete forces by-hand validation * of the route entry. Positive values are set by the generic
@@ -65,11 +64,12 @@ struct dst_entry {* Negative values are used by the implementation layer code to * force invocation of the dst_ops->check() method. */ -short obsolete; +s8 obsolete;#define DST_OBSOLETE_NONE 0#define DST_OBSOLETE_DEAD 2#define DST_OBSOLETE_FORCE_CHK -1#define DST_OBSOLETE_KILL -2 +u16 __pad2;unsigned short header_len;/* more space at head required */ unsigned short trailer_len;/* space to reserve at tail */
@@ -390,9 +390,9 @@ 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,dst_flags_t flags); +s8 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, +struct net_device *dev,int initial_ref,s8 initial_obsolete,dst_flags_t flags);struct dst_entry *dst_destroy (struct dst_entry *dst);void dst_dev_put (struct dst_entry *dst);
net/core/dst.c +2 -2
@@ -60,7 +60,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, +struct net_device *dev,int initial_ref,s8 initial_obsolete,dst_flags_t flags) { dst->dev = 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,dst_flags_t flags) +int initial_ref,s8 initial_obsolete,dst_flags_t flags) {struct dst_entry *dst;
Signature · 1 line
2.13.6
David Miller
maintainerA proper patch series must have a header posting.
The header posting must explain what the patch series is doing, how the patches in the series are related and therefore why they belong together as a group, how it is doing what it is doing, and why it is doing it that way.
Thank you.