mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-07 15:07:57 +07:00
ipv4: Namespaceify ip_default_ttl sysctl knob
Signed-off-by: Nikolay Borisov <kernel@kyup.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6cd21d7941
commit
fa50d974d1
@ -80,6 +80,7 @@ struct netns_ipv4 {
|
|||||||
int sysctl_tcp_ecn;
|
int sysctl_tcp_ecn;
|
||||||
int sysctl_tcp_ecn_fallback;
|
int sysctl_tcp_ecn_fallback;
|
||||||
|
|
||||||
|
int sysctl_ip_default_ttl;
|
||||||
int sysctl_ip_no_pmtu_disc;
|
int sysctl_ip_no_pmtu_disc;
|
||||||
int sysctl_ip_fwd_use_pmtu;
|
int sysctl_ip_fwd_use_pmtu;
|
||||||
int sysctl_ip_nonlocal_bind;
|
int sysctl_ip_nonlocal_bind;
|
||||||
|
@ -329,14 +329,13 @@ static inline int inet_iif(const struct sk_buff *skb)
|
|||||||
return skb->skb_iif;
|
return skb->skb_iif;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int sysctl_ip_default_ttl;
|
|
||||||
|
|
||||||
static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
|
static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
|
||||||
{
|
{
|
||||||
int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT);
|
int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT);
|
||||||
|
struct net *net = dev_net(dst->dev);
|
||||||
|
|
||||||
if (hoplimit == 0)
|
if (hoplimit == 0)
|
||||||
hoplimit = sysctl_ip_default_ttl;
|
hoplimit = net->ipv4.sysctl_ip_default_ttl;
|
||||||
return hoplimit;
|
return hoplimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ static void nft_reject_br_send_v4_tcp_reset(struct sk_buff *oldskb,
|
|||||||
struct iphdr *niph;
|
struct iphdr *niph;
|
||||||
const struct tcphdr *oth;
|
const struct tcphdr *oth;
|
||||||
struct tcphdr _oth;
|
struct tcphdr _oth;
|
||||||
|
struct net *net = sock_net(oldskb->sk);
|
||||||
|
|
||||||
if (!nft_bridge_iphdr_validate(oldskb))
|
if (!nft_bridge_iphdr_validate(oldskb))
|
||||||
return;
|
return;
|
||||||
@ -63,9 +64,9 @@ static void nft_reject_br_send_v4_tcp_reset(struct sk_buff *oldskb,
|
|||||||
|
|
||||||
skb_reserve(nskb, LL_MAX_HEADER);
|
skb_reserve(nskb, LL_MAX_HEADER);
|
||||||
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
|
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
|
||||||
sysctl_ip_default_ttl);
|
net->ipv4.sysctl_ip_default_ttl);
|
||||||
nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
|
nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
|
||||||
niph->ttl = sysctl_ip_default_ttl;
|
niph->ttl = net->ipv4.sysctl_ip_default_ttl;
|
||||||
niph->tot_len = htons(nskb->len);
|
niph->tot_len = htons(nskb->len);
|
||||||
ip_send_check(niph);
|
ip_send_check(niph);
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb,
|
|||||||
void *payload;
|
void *payload;
|
||||||
__wsum csum;
|
__wsum csum;
|
||||||
u8 proto;
|
u8 proto;
|
||||||
|
struct net *net = sock_net(oldskb->sk);
|
||||||
|
|
||||||
if (oldskb->csum_bad || !nft_bridge_iphdr_validate(oldskb))
|
if (oldskb->csum_bad || !nft_bridge_iphdr_validate(oldskb))
|
||||||
return;
|
return;
|
||||||
@ -119,7 +121,7 @@ static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb,
|
|||||||
|
|
||||||
skb_reserve(nskb, LL_MAX_HEADER);
|
skb_reserve(nskb, LL_MAX_HEADER);
|
||||||
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP,
|
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP,
|
||||||
sysctl_ip_default_ttl);
|
net->ipv4.sysctl_ip_default_ttl);
|
||||||
|
|
||||||
skb_reset_transport_header(nskb);
|
skb_reset_transport_header(nskb);
|
||||||
icmph = (struct icmphdr *)skb_put(nskb, sizeof(struct icmphdr));
|
icmph = (struct icmphdr *)skb_put(nskb, sizeof(struct icmphdr));
|
||||||
|
@ -79,9 +79,6 @@
|
|||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
#include <linux/tcp.h>
|
#include <linux/tcp.h>
|
||||||
|
|
||||||
int sysctl_ip_default_ttl __read_mostly = IPDEFTTL;
|
|
||||||
EXPORT_SYMBOL(sysctl_ip_default_ttl);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
|
ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
|
||||||
unsigned int mtu,
|
unsigned int mtu,
|
||||||
|
@ -1341,10 +1341,13 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
|
|||||||
val = inet->tos;
|
val = inet->tos;
|
||||||
break;
|
break;
|
||||||
case IP_TTL:
|
case IP_TTL:
|
||||||
|
{
|
||||||
|
struct net *net = sock_net(sk);
|
||||||
val = (inet->uc_ttl == -1 ?
|
val = (inet->uc_ttl == -1 ?
|
||||||
sysctl_ip_default_ttl :
|
net->ipv4.sysctl_ip_default_ttl :
|
||||||
inet->uc_ttl);
|
inet->uc_ttl);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IP_HDRINCL:
|
case IP_HDRINCL:
|
||||||
val = inet->hdrincl;
|
val = inet->hdrincl;
|
||||||
break;
|
break;
|
||||||
|
@ -21,6 +21,7 @@ static struct iphdr *
|
|||||||
synproxy_build_ip(struct sk_buff *skb, __be32 saddr, __be32 daddr)
|
synproxy_build_ip(struct sk_buff *skb, __be32 saddr, __be32 daddr)
|
||||||
{
|
{
|
||||||
struct iphdr *iph;
|
struct iphdr *iph;
|
||||||
|
struct net *net = sock_net(skb->sk);
|
||||||
|
|
||||||
skb_reset_network_header(skb);
|
skb_reset_network_header(skb);
|
||||||
iph = (struct iphdr *)skb_put(skb, sizeof(*iph));
|
iph = (struct iphdr *)skb_put(skb, sizeof(*iph));
|
||||||
@ -29,7 +30,7 @@ synproxy_build_ip(struct sk_buff *skb, __be32 saddr, __be32 daddr)
|
|||||||
iph->tos = 0;
|
iph->tos = 0;
|
||||||
iph->id = 0;
|
iph->id = 0;
|
||||||
iph->frag_off = htons(IP_DF);
|
iph->frag_off = htons(IP_DF);
|
||||||
iph->ttl = sysctl_ip_default_ttl;
|
iph->ttl = net->ipv4.sysctl_ip_default_ttl;
|
||||||
iph->protocol = IPPROTO_TCP;
|
iph->protocol = IPPROTO_TCP;
|
||||||
iph->check = 0;
|
iph->check = 0;
|
||||||
iph->saddr = saddr;
|
iph->saddr = saddr;
|
||||||
|
@ -390,7 +390,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
seq_printf(seq, "\nIp: %d %d",
|
seq_printf(seq, "\nIp: %d %d",
|
||||||
IPV4_DEVCONF_ALL(net, FORWARDING) ? 1 : 2,
|
IPV4_DEVCONF_ALL(net, FORWARDING) ? 1 : 2,
|
||||||
sysctl_ip_default_ttl);
|
net->ipv4.sysctl_ip_default_ttl);
|
||||||
|
|
||||||
BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0);
|
BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0);
|
||||||
for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
|
for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
|
||||||
|
@ -282,15 +282,6 @@ static struct ctl_table ipv4_table[] = {
|
|||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec
|
.proc_handler = proc_dointvec
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.procname = "ip_default_ttl",
|
|
||||||
.data = &sysctl_ip_default_ttl,
|
|
||||||
.maxlen = sizeof(int),
|
|
||||||
.mode = 0644,
|
|
||||||
.proc_handler = proc_dointvec_minmax,
|
|
||||||
.extra1 = &ip_ttl_min,
|
|
||||||
.extra2 = &ip_ttl_max,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.procname = "tcp_max_orphans",
|
.procname = "tcp_max_orphans",
|
||||||
.data = &sysctl_tcp_max_orphans,
|
.data = &sysctl_tcp_max_orphans,
|
||||||
@ -752,6 +743,15 @@ static struct ctl_table ipv4_net_table[] = {
|
|||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = proc_dointvec
|
.proc_handler = proc_dointvec
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.procname = "ip_default_ttl",
|
||||||
|
.data = &init_net.ipv4.sysctl_ip_default_ttl,
|
||||||
|
.maxlen = sizeof(int),
|
||||||
|
.mode = 0644,
|
||||||
|
.proc_handler = proc_dointvec_minmax,
|
||||||
|
.extra1 = &ip_ttl_min,
|
||||||
|
.extra2 = &ip_ttl_max,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.procname = "ip_local_port_range",
|
.procname = "ip_local_port_range",
|
||||||
.maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
|
.maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
|
||||||
@ -988,6 +988,8 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
|
|||||||
if (!net->ipv4.sysctl_local_reserved_ports)
|
if (!net->ipv4.sysctl_local_reserved_ports)
|
||||||
goto err_ports;
|
goto err_ports;
|
||||||
|
|
||||||
|
net->ipv4.sysctl_ip_default_ttl = IPDEFTTL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_ports:
|
err_ports:
|
||||||
|
Loading…
Reference in New Issue
Block a user