Skip to content

Commit 29bb43b

Browse files
herbertxdavem330
authored andcommitted
[INET]: Give outer DSCP directly to ip*_copy_dscp
This patch changes the prototype of ipv4_copy_dscp and ipv6_copy_dscp so that they directly take the outer DSCP rather than the outer IP header. This will help us to unify the code for inter-family tunnels. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a2deb6d commit 29bb43b

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎include/net/inet_ecn.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ static inline void IP_ECN_clear(struct iphdr *iph)
8383
iph->tos &= ~INET_ECN_MASK;
8484
}
8585

86-
static inline void ipv4_copy_dscp(struct iphdr *outer, struct iphdr *inner)
86+
static inline void ipv4_copy_dscp(unsigned int dscp, struct iphdr *inner)
8787
{
88-
u32 dscp = ipv4_get_dsfield(outer) & ~INET_ECN_MASK;
88+
dscp &= ~INET_ECN_MASK;
8989
ipv4_change_dsfield(inner, INET_ECN_MASK, dscp);
9090
}
9191

@@ -104,9 +104,9 @@ static inline void IP6_ECN_clear(struct ipv6hdr *iph)
104104
*(__be32*)iph &= ~htonl(INET_ECN_MASK << 20);
105105
}
106106

107-
static inline void ipv6_copy_dscp(struct ipv6hdr *outer, struct ipv6hdr *inner)
107+
static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
108108
{
109-
u32 dscp = ipv6_get_dsfield(outer) & ~INET_ECN_MASK;
109+
dscp &= ~INET_ECN_MASK;
110110
ipv6_change_dsfield(inner, INET_ECN_MASK, dscp);
111111
}
112112

‎net/ipv4/xfrm4_mode_tunnel.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
113113
iph = ip_hdr(skb);
114114
if (iph->protocol == IPPROTO_IPIP) {
115115
if (x->props.flags & XFRM_STATE_DECAP_DSCP)
116-
ipv4_copy_dscp(iph, ipip_hdr(skb));
116+
ipv4_copy_dscp(ipv4_get_dsfield(iph), ipip_hdr(skb));
117117
if (!(x->props.flags & XFRM_STATE_NOECN))
118118
ipip_ecn_decapsulate(skb);
119119
}

‎net/ipv6/ip6_tunnel.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static void ip6ip6_dscp_ecn_decapsulate(struct ip6_tnl *t,
635635
struct sk_buff *skb)
636636
{
637637
if (t->parms.flags & IP6_TNL_F_RCV_DSCP_COPY)
638-
ipv6_copy_dscp(ipv6h, ipv6_hdr(skb));
638+
ipv6_copy_dscp(ipv6_get_dsfield(ipv6h), ipv6_hdr(skb));
639639

640640
if (INET_ECN_is_ce(ipv6_get_dsfield(ipv6h)))
641641
IP6_ECN_set_ce(ipv6_hdr(skb));

‎net/ipv6/xfrm6_mode_tunnel.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
9595
nh = skb_network_header(skb);
9696
if (nh[IP6CB(skb)->nhoff] == IPPROTO_IPV6) {
9797
if (x->props.flags & XFRM_STATE_DECAP_DSCP)
98-
ipv6_copy_dscp(ipv6_hdr(skb), ipipv6_hdr(skb));
98+
ipv6_copy_dscp(ipv6_get_dsfield(ipv6_hdr(skb)),
99+
ipipv6_hdr(skb));
99100
if (!(x->props.flags & XFRM_STATE_NOECN))
100101
ipip6_ecn_decapsulate(skb);
101102
} else {

0 commit comments

Comments
 (0)