提交 dae7bed9 编写于 作者: W Wei Yongjun 提交者: Zheng Zengkai

tcp_comp: add sysctl for enable/disable compression

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4PNEK
CVE: NA

-------------------------------------------------

Add sysctl interface for enable/disable tcp compression by ports.

Example:

$ echo 4000 > /proc/sys/net/ipv4/tcp_compression_ports
will enable port 4000 for tcp compression

$ echo 4000,5000 > /proc/sys/net/ipv4/tcp_compression_ports
will enable both port 4000 and 5000 for tcp compression

$ echo > /proc/sys/net/ipv4/tcp_compression_ports
will disable tcp compression.
Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLu Wei <luwei32@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 cc36784b
...@@ -2382,6 +2382,9 @@ static inline u64 tcp_transmit_time(const struct sock *sk) ...@@ -2382,6 +2382,9 @@ static inline u64 tcp_transmit_time(const struct sock *sk)
#if IS_ENABLED(CONFIG_TCP_COMP) #if IS_ENABLED(CONFIG_TCP_COMP)
extern struct static_key_false tcp_have_comp; extern struct static_key_false tcp_have_comp;
extern unsigned long *sysctl_tcp_compression_ports;
bool tcp_syn_comp_enabled(const struct tcp_sock *tp); bool tcp_syn_comp_enabled(const struct tcp_sock *tp);
void tcp_init_compression(struct sock *sk); void tcp_init_compression(struct sock *sk);
void tcp_cleanup_compression(struct sock *sk); void tcp_cleanup_compression(struct sock *sk);
......
...@@ -465,6 +465,30 @@ static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write, ...@@ -465,6 +465,30 @@ static int proc_fib_multipath_hash_policy(struct ctl_table *table, int write,
} }
#endif #endif
#if IS_ENABLED(CONFIG_TCP_COMP)
static int proc_tcp_compression_ports(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
unsigned long *bitmap = *(unsigned long **)table->data;
unsigned long bitmap_len = table->maxlen;
int ret;
ret = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
if (write && ret == 0) {
if (bitmap_empty(bitmap, bitmap_len)) {
if (static_key_enabled(&tcp_have_comp))
static_branch_disable(&tcp_have_comp);
} else {
if (!static_key_enabled(&tcp_have_comp))
static_branch_enable(&tcp_have_comp);
}
}
return ret;
}
#endif
static struct ctl_table ipv4_table[] = { static struct ctl_table ipv4_table[] = {
{ {
.procname = "tcp_max_orphans", .procname = "tcp_max_orphans",
...@@ -588,6 +612,15 @@ static struct ctl_table ipv4_table[] = { ...@@ -588,6 +612,15 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_do_static_key, .proc_handler = proc_do_static_key,
}, },
#if IS_ENABLED(CONFIG_TCP_COMP)
{
.procname = "tcp_compression_ports",
.data = &sysctl_tcp_compression_ports,
.maxlen = 65536,
.mode = 0644,
.proc_handler = proc_tcp_compression_ports,
},
#endif
{ } { }
}; };
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#include <net/tcp.h> #include <net/tcp.h>
static unsigned long tcp_compression_ports[65536 / 8];
unsigned long *sysctl_tcp_compression_ports = tcp_compression_ports;
bool tcp_syn_comp_enabled(const struct tcp_sock *tp) bool tcp_syn_comp_enabled(const struct tcp_sock *tp)
{ {
return true; return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册