Skip to content

Commit a346abe

Browse files
edumazetdavem330
authored andcommitted
ipv6: icmp: allow flowlabel reflection in echo replies
Extend flowlabel_reflect bitmask to allow conditional reflection of incoming flowlabels in echo replies. Note this has precedence against auto flowlabels. Add flowlabel_reflect enum to replace hard coded values. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 954a5a0 commit a346abe

6 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎Documentation/networking/ip-sysctl.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ flowlabel_reflect - INTEGER
14521452
environments. See RFC 7690 and:
14531453
https://tools.ietf.org/html/draft-wang-6man-flow-label-reflection-01
14541454

1455-
This is a mask of two bits.
1455+
This is a bitmask.
14561456
1: enabled for established flows
14571457

14581458
Note that this prevents automatic flowlabel changes, as done
@@ -1463,6 +1463,8 @@ flowlabel_reflect - INTEGER
14631463
If set, a RST packet sent in response to a SYN packet on a closed
14641464
port will reflect the incoming flow label.
14651465

1466+
4: enabled for ICMPv6 echo reply messages.
1467+
14661468
Default: 0
14671469

14681470
fib_multipath_hash_policy - INTEGER

‎include/net/ipv6.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ struct ipv6_txoptions {
301301
/* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */
302302
};
303303

304+
/* flowlabel_reflect sysctl values */
305+
enum flowlabel_reflect {
306+
FLOWLABEL_REFLECT_ESTABLISHED = 1,
307+
FLOWLABEL_REFLECT_TCP_RESET = 2,
308+
FLOWLABEL_REFLECT_ICMPV6_ECHO_REPLIES = 4,
309+
};
310+
304311
struct ip6_flowlabel {
305312
struct ip6_flowlabel __rcu *next;
306313
__be32 label;

‎net/ipv6/af_inet6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
208208
np->mc_loop = 1;
209209
np->mc_all = 1;
210210
np->pmtudisc = IPV6_PMTUDISC_WANT;
211-
np->repflow = net->ipv6.sysctl.flowlabel_reflect & 1;
211+
np->repflow = net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_ESTABLISHED;
212212
sk->sk_ipv6only = net->ipv6.sysctl.bindv6only;
213213

214214
/* Init the ipv4 part of the socket since we can have sockets

‎net/ipv6/icmp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
703703
tmp_hdr.icmp6_type = ICMPV6_ECHO_REPLY;
704704

705705
memset(&fl6, 0, sizeof(fl6));
706+
if (net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_ICMPV6_ECHO_REPLIES)
707+
fl6.flowlabel = ip6_flowlabel(ipv6_hdr(skb));
708+
706709
fl6.flowi6_proto = IPPROTO_ICMPV6;
707710
fl6.daddr = ipv6_hdr(skb)->saddr;
708711
if (saddr)

‎net/ipv6/sysctl_net_ipv6.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
static int zero;
2525
static int one = 1;
26-
static int three = 3;
26+
static int flowlabel_reflect_max = 0x7;
2727
static int auto_flowlabels_min;
2828
static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX;
2929

@@ -116,7 +116,7 @@ static struct ctl_table ipv6_table_template[] = {
116116
.mode = 0644,
117117
.proc_handler = proc_dointvec,
118118
.extra1 = &zero,
119-
.extra2 = &three,
119+
.extra2 = &flowlabel_reflect_max,
120120
},
121121
{
122122
.procname = "max_dst_opts_number",

‎net/ipv6/tcp_ipv6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)
989989
if (sk->sk_state == TCP_TIME_WAIT)
990990
label = cpu_to_be32(inet_twsk(sk)->tw_flowlabel);
991991
} else {
992-
if (net->ipv6.sysctl.flowlabel_reflect & 2)
992+
if (net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_TCP_RESET)
993993
label = ip6_flowlabel(ipv6h);
994994
}
995995

0 commit comments

Comments
 (0)