Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Change nhc_flags to unsigned char

nhc_flags holds the RTNH_F flags for a given nexthop (fib{6}_nh).
All of the RTNH_F_ flags fit in an unsigned char, and since the API to
userspace (rtnh_flags and lower byte of rtm_flags) is 1 byte it can not
grow. Make nhc_flags in fib_nh_common an unsigned char and shrink the
size of the struct by 8, from 56 to 48 bytes.

Update the flags arguments for up netdevice events and fib_nexthop_info
which determines the RTNH_F flags to return on a dump/event. The RTNH_F
flags are passed in the lower byte of rtm_flags which is an unsigned int
so use a temp variable for the flags to fib_nexthop_info and combine
with rtm_flags in the caller.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

David Ahern and committed by
David S. Miller
ecc5663c ffa8ce54

+17 -13
+1 -1
include/net/ip6_route.h
··· 182 182 void rt6_mtu_change(struct net_device *dev, unsigned int mtu); 183 183 void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); 184 184 void rt6_clean_tohost(struct net *net, struct in6_addr *gateway); 185 - void rt6_sync_up(struct net_device *dev, unsigned int nh_flags); 185 + void rt6_sync_up(struct net_device *dev, unsigned char nh_flags); 186 186 void rt6_disable_ip(struct net_device *dev, unsigned long event); 187 187 void rt6_sync_down_dev(struct net_device *dev, unsigned long event); 188 188 void rt6_multipath_rebalance(struct fib6_info *f6i);
+4 -4
include/net/ip_fib.h
··· 83 83 struct fib_nh_common { 84 84 struct net_device *nhc_dev; 85 85 int nhc_oif; 86 - unsigned int nhc_flags; 87 - struct lwtunnel_state *nhc_lwtstate; 88 86 unsigned char nhc_scope; 89 87 u8 nhc_family; 90 88 u8 nhc_gw_family; 89 + unsigned char nhc_flags; 90 + struct lwtunnel_state *nhc_lwtstate; 91 91 92 92 union { 93 93 __be32 ipv4; ··· 425 425 int ip_fib_check_default(__be32 gw, struct net_device *dev); 426 426 int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force); 427 427 int fib_sync_down_addr(struct net_device *dev, __be32 local); 428 - int fib_sync_up(struct net_device *dev, unsigned int nh_flags); 428 + int fib_sync_up(struct net_device *dev, unsigned char nh_flags); 429 429 void fib_sync_mtu(struct net_device *dev, u32 orig_mtu); 430 430 431 431 #ifdef CONFIG_IP_ROUTE_MULTIPATH ··· 500 500 struct netlink_callback *cb); 501 501 502 502 int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nh, 503 - unsigned int *flags, bool skip_oif); 503 + unsigned char *flags, bool skip_oif); 504 504 int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nh, 505 505 int nh_weight); 506 506 #endif /* _NET_FIB_H */
+4 -4
net/ipv4/fib_semantics.c
··· 1444 1444 } 1445 1445 1446 1446 int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nhc, 1447 - unsigned int *flags, bool skip_oif) 1447 + unsigned char *flags, bool skip_oif) 1448 1448 { 1449 1449 if (nhc->nhc_flags & RTNH_F_DEAD) 1450 1450 *flags |= RTNH_F_DEAD; ··· 1520 1520 { 1521 1521 const struct net_device *dev = nhc->nhc_dev; 1522 1522 struct rtnexthop *rtnh; 1523 - unsigned int flags = 0; 1523 + unsigned char flags = 0; 1524 1524 1525 1525 rtnh = nla_reserve_nohdr(skb, sizeof(*rtnh)); 1526 1526 if (!rtnh) ··· 1619 1619 goto nla_put_failure; 1620 1620 if (fi->fib_nhs == 1) { 1621 1621 struct fib_nh *nh = &fi->fib_nh[0]; 1622 - unsigned int flags = 0; 1622 + unsigned char flags = 0; 1623 1623 1624 1624 if (fib_nexthop_info(skb, &nh->nh_common, &flags, false) < 0) 1625 1625 goto nla_put_failure; ··· 1902 1902 * Dead device goes up. We wake up dead nexthops. 1903 1903 * It takes sense only on multipath routes. 1904 1904 */ 1905 - int fib_sync_up(struct net_device *dev, unsigned int nh_flags) 1905 + int fib_sync_up(struct net_device *dev, unsigned char nh_flags) 1906 1906 { 1907 1907 struct fib_info *prev_fi; 1908 1908 unsigned int hash;
+8 -4
net/ipv6/route.c
··· 3912 3912 struct arg_netdev_event { 3913 3913 const struct net_device *dev; 3914 3914 union { 3915 - unsigned int nh_flags; 3915 + unsigned char nh_flags; 3916 3916 unsigned long event; 3917 3917 }; 3918 3918 }; ··· 4025 4025 return 0; 4026 4026 } 4027 4027 4028 - void rt6_sync_up(struct net_device *dev, unsigned int nh_flags) 4028 + void rt6_sync_up(struct net_device *dev, unsigned char nh_flags) 4029 4029 { 4030 4030 struct arg_netdev_event arg = { 4031 4031 .dev = dev, ··· 4082 4082 4083 4083 static void rt6_multipath_nh_flags_set(struct fib6_info *rt, 4084 4084 const struct net_device *dev, 4085 - unsigned int nh_flags) 4085 + unsigned char nh_flags) 4086 4086 { 4087 4087 struct fib6_info *iter; 4088 4088 ··· 4794 4794 4795 4795 nla_nest_end(skb, mp); 4796 4796 } else { 4797 + unsigned char nh_flags = 0; 4798 + 4797 4799 if (fib_nexthop_info(skb, &rt->fib6_nh.nh_common, 4798 - &rtm->rtm_flags, false) < 0) 4800 + &nh_flags, false) < 0) 4799 4801 goto nla_put_failure; 4802 + 4803 + rtm->rtm_flags |= nh_flags; 4800 4804 } 4801 4805 4802 4806 if (rt6_flags & RTF_EXPIRES) {