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

Merge branch 'mpls-cleanups'

Benjamin Poirier says:

====================
net: mpls: Cleanup nexthop iterator macros

The mpls macros for_nexthops and change_nexthops were probably copied
from decnet or ipv4 but they grew a superfluous variable and lost a
beneficial "const".
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+10 -11
+4 -4
net/mpls/af_mpls.c
··· 230 230 * Since those fields can change at any moment, use READ_ONCE to 231 231 * access both. 232 232 */ 233 - static struct mpls_nh *mpls_select_multipath(struct mpls_route *rt, 234 - struct sk_buff *skb) 233 + static const struct mpls_nh *mpls_select_multipath(struct mpls_route *rt, 234 + struct sk_buff *skb) 235 235 { 236 236 u32 hash = 0; 237 237 int nh_index = 0; ··· 343 343 { 344 344 struct net *net = dev_net(dev); 345 345 struct mpls_shim_hdr *hdr; 346 + const struct mpls_nh *nh; 346 347 struct mpls_route *rt; 347 - struct mpls_nh *nh; 348 348 struct mpls_entry_decoded dec; 349 349 struct net_device *out_dev; 350 350 struct mpls_dev *out_mdev; ··· 2333 2333 u32 labels[MAX_NEW_LABELS]; 2334 2334 struct mpls_shim_hdr *hdr; 2335 2335 unsigned int hdr_size = 0; 2336 + const struct mpls_nh *nh; 2336 2337 struct net_device *dev; 2337 2338 struct mpls_route *rt; 2338 2339 struct rtmsg *rtm, *r; 2339 2340 struct nlmsghdr *nlh; 2340 2341 struct sk_buff *skb; 2341 - struct mpls_nh *nh; 2342 2342 u8 n_labels; 2343 2343 int err; 2344 2344
+6 -7
net/mpls/internal.h
··· 158 158 }; 159 159 160 160 #define for_nexthops(rt) { \ 161 - int nhsel; struct mpls_nh *nh; u8 *__nh; \ 162 - for (nhsel = 0, nh = (rt)->rt_nh, __nh = (u8 *)((rt)->rt_nh); \ 161 + int nhsel; const struct mpls_nh *nh; \ 162 + for (nhsel = 0, nh = (rt)->rt_nh; \ 163 163 nhsel < (rt)->rt_nhn; \ 164 - __nh += rt->rt_nh_size, nh = (struct mpls_nh *)__nh, nhsel++) 164 + nh = (void *)nh + (rt)->rt_nh_size, nhsel++) 165 165 166 166 #define change_nexthops(rt) { \ 167 - int nhsel; struct mpls_nh *nh; u8 *__nh; \ 168 - for (nhsel = 0, nh = (struct mpls_nh *)((rt)->rt_nh), \ 169 - __nh = (u8 *)((rt)->rt_nh); \ 167 + int nhsel; struct mpls_nh *nh; \ 168 + for (nhsel = 0, nh = (rt)->rt_nh; \ 170 169 nhsel < (rt)->rt_nhn; \ 171 - __nh += rt->rt_nh_size, nh = (struct mpls_nh *)__nh, nhsel++) 170 + nh = (void *)nh + (rt)->rt_nh_size, nhsel++) 172 171 173 172 #define endfor_nexthops(rt) } 174 173