net: ipv4: Control SKB reprioritization after forwarding
After IPv4 packets are forwarded, the priority of the corresponding SKB is updated according to the TOS field of IPv4 header. This overrides any prioritization done earlier by e.g. an skbedit action or ingress-qos-map defined at a vlan device. Such overriding may not always be desirable. Even if the packet ends up being routed, which implies this is an L3 network node, an administrator may wish to preserve whatever prioritization was done earlier on in the pipeline. Therefore introduce a sysctl that controls this behavior. Keep the default value at 1 to maintain backward-compatible behavior. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
83ba464515
commit
432e05d328
@@ -1801,6 +1801,7 @@ static __net_init int inet_init_net(struct net *net)
|
||||
* We set them here, in case sysctl is not compiled.
|
||||
*/
|
||||
net->ipv4.sysctl_ip_default_ttl = IPDEFTTL;
|
||||
net->ipv4.sysctl_ip_fwd_update_priority = 1;
|
||||
net->ipv4.sysctl_ip_dynaddr = 0;
|
||||
net->ipv4.sysctl_ip_early_demux = 1;
|
||||
net->ipv4.sysctl_udp_early_demux = 1;
|
||||
|
||||
@@ -143,7 +143,8 @@ int ip_forward(struct sk_buff *skb)
|
||||
!skb_sec_path(skb))
|
||||
ip_rt_send_redirect(skb);
|
||||
|
||||
skb->priority = rt_tos2priority(iph->tos);
|
||||
if (net->ipv4.sysctl_ip_fwd_update_priority)
|
||||
skb->priority = rt_tos2priority(iph->tos);
|
||||
|
||||
return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
|
||||
net, NULL, skb, skb->dev, rt->dst.dev,
|
||||
|
||||
@@ -663,6 +663,15 @@ static struct ctl_table ipv4_net_table[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{
|
||||
.procname = "ip_forward_update_priority",
|
||||
.data = &init_net.ipv4.sysctl_ip_fwd_update_priority,
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_minmax,
|
||||
.extra1 = &zero,
|
||||
.extra2 = &one,
|
||||
},
|
||||
{
|
||||
.procname = "ip_nonlocal_bind",
|
||||
.data = &init_net.ipv4.sysctl_ip_nonlocal_bind,
|
||||
|
||||
Reference in New Issue
Block a user