Skip to content

Commit

Permalink
Merge branch 'mpls-cleanups'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Nov 29, 2021
2 parents 688e075 + f05b0b9 commit fe42e88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions net/mpls/af_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ static struct mpls_nh *mpls_get_nexthop(struct mpls_route *rt, u8 index)
* Since those fields can change at any moment, use READ_ONCE to
* access both.
*/
static struct mpls_nh *mpls_select_multipath(struct mpls_route *rt,
struct sk_buff *skb)
static const struct mpls_nh *mpls_select_multipath(struct mpls_route *rt,
struct sk_buff *skb)
{
u32 hash = 0;
int nh_index = 0;
Expand Down Expand Up @@ -343,8 +343,8 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev,
{
struct net *net = dev_net(dev);
struct mpls_shim_hdr *hdr;
const struct mpls_nh *nh;
struct mpls_route *rt;
struct mpls_nh *nh;
struct mpls_entry_decoded dec;
struct net_device *out_dev;
struct mpls_dev *out_mdev;
Expand Down Expand Up @@ -2333,12 +2333,12 @@ static int mpls_getroute(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
u32 labels[MAX_NEW_LABELS];
struct mpls_shim_hdr *hdr;
unsigned int hdr_size = 0;
const struct mpls_nh *nh;
struct net_device *dev;
struct mpls_route *rt;
struct rtmsg *rtm, *r;
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct mpls_nh *nh;
u8 n_labels;
int err;

Expand Down
13 changes: 6 additions & 7 deletions net/mpls/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,16 @@ struct mpls_route { /* next hop label forwarding entry */
};

#define for_nexthops(rt) { \
int nhsel; struct mpls_nh *nh; u8 *__nh; \
for (nhsel = 0, nh = (rt)->rt_nh, __nh = (u8 *)((rt)->rt_nh); \
int nhsel; const struct mpls_nh *nh; \
for (nhsel = 0, nh = (rt)->rt_nh; \
nhsel < (rt)->rt_nhn; \
__nh += rt->rt_nh_size, nh = (struct mpls_nh *)__nh, nhsel++)
nh = (void *)nh + (rt)->rt_nh_size, nhsel++)

#define change_nexthops(rt) { \
int nhsel; struct mpls_nh *nh; u8 *__nh; \
for (nhsel = 0, nh = (struct mpls_nh *)((rt)->rt_nh), \
__nh = (u8 *)((rt)->rt_nh); \
int nhsel; struct mpls_nh *nh; \
for (nhsel = 0, nh = (rt)->rt_nh; \
nhsel < (rt)->rt_nhn; \
__nh += rt->rt_nh_size, nh = (struct mpls_nh *)__nh, nhsel++)
nh = (void *)nh + (rt)->rt_nh_size, nhsel++)

#define endfor_nexthops(rt) }

Expand Down

0 comments on commit fe42e88

Please sign in to comment.