Skip to content

Commit

Permalink
support linux 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boyu committed Aug 23, 2019
1 parent 3d1d2fc commit 5b810f7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ get ip vs(fullnat) client addr

由taobao/toa修改,可作为独立模块编译安装, 支持tcp/udp

支持 centos6.6(linux 2.6.32-220) / centos7.2(linux 3.10.0-237.4.5) / ubuntu14.04(linux 3.13.0-77-generic) / ubuntu16.04(linux 4.4.0-64-generic) / centos7.2(linux 4.9.2-1.el7)
支持 centos6.6(linux 2.6.32-220) / centos7.2(linux 3.10.0-237.4.5) / ubuntu14.04(linux 3.13.0-77-generic) / ubuntu16.04(linux 4.4.0-64-generic) / centos7.2(linux 4.9.2-1.el7) / ubuntu19.04 (5.0.0-25-generic)

对应内核在[github.com/yubo/LVS](https://github.com/yubo/LVS/tree/lvs_v2),兼容[taobao/LVS(lvs_v2)](https://github.com/alibaba/LVS/tree/lvs_v2)

Expand All @@ -23,6 +23,8 @@ get ip vs(fullnat) client addr
- [x] Support centos 7.2 rpmbuild
- [x] Support ubuntu 14.04(trusty) dpkg
- [x] Support ubuntu 16.04.2(xenial) dpkg
- [x] Support ubuntu 19.04(disco) dpkg (untested)
- [x] Linux (2.6.32 - 5.0.0)

## Demo

Expand Down
10 changes: 10 additions & 0 deletions src/ca_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,15 @@ ip_vs_ca_conn_unhash(struct ip_vs_ca_conn *cp)
return ret;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
static void ip_vs_ca_conn_expire(struct timer_list *t)
{
struct ip_vs_ca_conn *cp = from_timer(cp, t, timer);
#else
static void ip_vs_ca_conn_expire(unsigned long data)
{
struct ip_vs_ca_conn *cp = (struct ip_vs_ca_conn *)data;
#endif

/*
* Set proper timeout.
Expand Down Expand Up @@ -260,7 +266,11 @@ struct ip_vs_ca_conn *ip_vs_ca_conn_new(int af,

/* now init connection */
IP_VS_CA_DBG("setup_timer, %p\n", &cp->timer);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)
timer_setup(&cp->timer, ip_vs_ca_conn_expire, 0);
#else
setup_timer(&cp->timer, ip_vs_ca_conn_expire, (unsigned long)cp);
#endif
cp->af = af;
cp->protocol = pp->protocol;
//ip_vs_ca_addr_copy(af, &cp->saddr, saddr);
Expand Down
21 changes: 15 additions & 6 deletions src/ca_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,24 +303,25 @@ static void ip_vs_ca_syscall_cleanup(void)

static unsigned int _ip_vs_ca_in_hook(struct sk_buff *skb);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
static unsigned int
ip_vs_ca_in_hook(void *priv, struct sk_buff *skb,
const struct nf_hook_state *state)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
static unsigned int
ip_vs_ca_in_hook(const struct nf_hook_ops *ops, struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
const void *ignore)
{
return _ip_vs_ca_in_hook(skb);
}
#else
static unsigned int
ip_vs_ca_in_hook(unsigned int hooknum, struct sk_buff *skb,
const struct net_device *in, const struct net_device *out,
int (*okfn) (struct sk_buff *))
#endif
{
return _ip_vs_ca_in_hook(skb);
}
#endif

static unsigned int _ip_vs_ca_in_hook(struct sk_buff *skb)
{
Expand Down Expand Up @@ -496,7 +497,11 @@ static int __init ip_vs_ca_init(void)
}
IP_VS_CA_DBG("ip_vs_ca_conn_init done.\n");

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
ret = nf_register_net_hooks(NULL, ip_vs_ca_ops, ARRAY_SIZE(ip_vs_ca_ops));
#else
ret = nf_register_hooks(ip_vs_ca_ops, ARRAY_SIZE(ip_vs_ca_ops));
#endif
if (ret < 0){
IP_VS_CA_ERR("can't register hooks.\n");
goto cleanup_conn;
Expand All @@ -518,7 +523,11 @@ static int __init ip_vs_ca_init(void)

static void __exit ip_vs_ca_exit(void)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
nf_unregister_net_hooks(NULL, ip_vs_ca_ops, ARRAY_SIZE(ip_vs_ca_ops));
#else
nf_unregister_hooks(ip_vs_ca_ops, ARRAY_SIZE(ip_vs_ca_ops));
#endif
ip_vs_ca_conn_cleanup();
ip_vs_ca_protocol_cleanup();
ip_vs_ca_control_cleanup();
Expand Down
4 changes: 4 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <linux/syscalls.h>
#include "ca.h"

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0)
#define sys_close ksys_close
#endif

unsigned long **find_sys_call_table(void) {

unsigned long ptr;
Expand Down

0 comments on commit 5b810f7

Please sign in to comment.