Skip to content

Commit af2c4fa

Browse files
committed
Merge branch 'xfrm: Convert __xfrm4_dst_lookup() and its callers to dscp_t.'
Guillaume Nault says: ==================== This patch series continues to prepare users of ->flowi4_tos to a future conversion of this field (__u8 to dscp_t). This time, we convert __xfrm4_dst_lookup() and its call chain. The objective is to eventually make all users of ->flowi4_tos use a dscp_t value. Making ->flowi4_tos a dscp_t field will help avoiding regressions where ECN bits are erroneously interpreted as DSCP bits. ==================== Signed-off-by: Steffen Klassert <[email protected]>
2 parents 83dfce3 + e57dfaa commit af2c4fa

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

include/net/xfrm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <net/sock.h>
2121
#include <net/dst.h>
22+
#include <net/inet_dscp.h>
2223
#include <net/ip.h>
2324
#include <net/route.h>
2425
#include <net/ipv6.h>
@@ -354,7 +355,7 @@ void xfrm_if_unregister_cb(void);
354355

355356
struct xfrm_dst_lookup_params {
356357
struct net *net;
357-
int tos;
358+
dscp_t dscp;
358359
int oif;
359360
xfrm_address_t *saddr;
360361
xfrm_address_t *daddr;

net/ipv4/xfrm4_policy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/inetdevice.h>
1515
#include <net/dst.h>
1616
#include <net/xfrm.h>
17+
#include <net/inet_dscp.h>
1718
#include <net/ip.h>
1819
#include <net/l3mdev.h>
1920

@@ -24,7 +25,7 @@ static struct dst_entry *__xfrm4_dst_lookup(struct flowi4 *fl4,
2425

2526
memset(fl4, 0, sizeof(*fl4));
2627
fl4->daddr = params->daddr->a4;
27-
fl4->flowi4_tos = params->tos;
28+
fl4->flowi4_tos = inet_dscp_to_dsfield(params->dscp);
2829
fl4->flowi4_l3mdev = l3mdev_master_ifindex_by_index(params->net,
2930
params->oif);
3031
fl4->flowi4_mark = params->mark;

net/xfrm/xfrm_policy.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ struct dst_entry *__xfrm_dst_lookup(int family,
289289
EXPORT_SYMBOL(__xfrm_dst_lookup);
290290

291291
static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,
292-
int tos, int oif,
292+
dscp_t dscp, int oif,
293293
xfrm_address_t *prev_saddr,
294294
xfrm_address_t *prev_daddr,
295295
int family, u32 mark)
@@ -312,7 +312,7 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,
312312
params.net = net;
313313
params.saddr = saddr;
314314
params.daddr = daddr;
315-
params.tos = tos;
315+
params.dscp = dscp;
316316
params.oif = oif;
317317
params.mark = mark;
318318
params.ipproto = x->id.proto;
@@ -2587,10 +2587,10 @@ xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl,
25872587

25882588
}
25892589

2590-
static int xfrm_get_tos(const struct flowi *fl, int family)
2590+
static dscp_t xfrm_get_dscp(const struct flowi *fl, int family)
25912591
{
25922592
if (family == AF_INET)
2593-
return fl->u.ip4.flowi4_tos & INET_DSCP_MASK;
2593+
return inet_dsfield_to_dscp(fl->u.ip4.flowi4_tos);
25942594

25952595
return 0;
25962596
}
@@ -2678,13 +2678,13 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
26782678
int header_len = 0;
26792679
int nfheader_len = 0;
26802680
int trailer_len = 0;
2681-
int tos;
26822681
int family = policy->selector.family;
26832682
xfrm_address_t saddr, daddr;
2683+
dscp_t dscp;
26842684

26852685
xfrm_flowi_addr_get(fl, &saddr, &daddr, family);
26862686

2687-
tos = xfrm_get_tos(fl, family);
2687+
dscp = xfrm_get_dscp(fl, family);
26882688

26892689
dst_hold(dst);
26902690

@@ -2732,8 +2732,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
27322732
family = xfrm[i]->props.family;
27332733

27342734
oif = fl->flowi_oif ? : fl->flowi_l3mdev;
2735-
dst = xfrm_dst_lookup(xfrm[i], tos, oif,
2736-
&saddr, &daddr, family, mark);
2735+
dst = xfrm_dst_lookup(xfrm[i], dscp, oif, &saddr,
2736+
&daddr, family, mark);
27372737
err = PTR_ERR(dst);
27382738
if (IS_ERR(dst))
27392739
goto put_states;

0 commit comments

Comments
 (0)