net: add a sysctl to reflect the fwmark on replies
Kernel-originated IP packets that have no user socket associated with them (e.g., ICMP errors and echo replies, TCP RSTs, etc.) are emitted with a mark of zero. Add a sysctl to make them have the same mark as the packet they are replying to. This allows an administrator that wishes to do so to use mark-based routing, firewalling, etc. for these replies by marking the original packets inbound. Tested using user-mode linux: - ICMP/ICMPv6 echo replies and errors. - TCP RST packets (IPv4 and IPv6). Signed-off-by: Lorenzo Colitti <lorenzo@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
87e067cda6
commit
e110861f86
@@ -231,6 +231,9 @@ void ipfrag_init(void);
|
||||
|
||||
void ip_static_sysctl_init(void);
|
||||
|
||||
#define IP4_REPLY_MARK(net, mark) \
|
||||
((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0)
|
||||
|
||||
static inline bool ip_is_fragment(const struct iphdr *iph)
|
||||
{
|
||||
return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0;
|
||||
|
||||
@@ -113,6 +113,9 @@ struct frag_hdr {
|
||||
#define IP6_MF 0x0001
|
||||
#define IP6_OFFSET 0xFFF8
|
||||
|
||||
#define IP6_REPLY_MARK(net, mark) \
|
||||
((net)->ipv6.sysctl.fwmark_reflect ? (mark) : 0)
|
||||
|
||||
#include <net/sock.h>
|
||||
|
||||
/* sysctls */
|
||||
|
||||
@@ -77,6 +77,8 @@ struct netns_ipv4 {
|
||||
int sysctl_ip_no_pmtu_disc;
|
||||
int sysctl_ip_fwd_use_pmtu;
|
||||
|
||||
int sysctl_fwmark_reflect;
|
||||
|
||||
struct ping_group_range ping_group_range;
|
||||
|
||||
atomic_t dev_addr_genid;
|
||||
|
||||
@@ -30,6 +30,7 @@ struct netns_sysctl_ipv6 {
|
||||
int flowlabel_consistency;
|
||||
int icmpv6_time;
|
||||
int anycast_src_echo_reply;
|
||||
int fwmark_reflect;
|
||||
};
|
||||
|
||||
struct netns_ipv6 {
|
||||
|
||||
Reference in New Issue
Block a user