diff --git a/Makefile b/Makefile index 2f3677f..fce7667 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,53 @@ + +RHEL8 := $(shell cat /etc/redhat-release 2>/dev/null | grep -c " 8." ) +ifneq (,$(findstring 1, $(RHEL8))) + RHEL8FLAG := -DRHEL8 +endif + PWD := $(shell pwd) -KVERSION := $(shell uname -r) -INCLUDE_DIR = /usr/src/linux-headers-$(KVERSION)/ + +ifeq ($(KVER),) + KVER := $(shell uname -r) + endif + +ifneq ($(RUN_DEPMOD),) + DEPMOD := /sbin/depmod -a + else + DEPMOD := true + endif + +ifeq ($(KDIR),) + KDIR := /lib/modules/$(KVER)/build + endif + CONFIG_MODULE_SIG=n MODULE_NAME = gtp5g -MY_CFLAGS += -g -DDEBUG +MY_CFLAGS += -g -DDEBUG $(RHEL8FLAG) EXTRA_CFLAGS += -Wno-misleading-indentation -Wuninitialized CC += ${MY_CFLAGS} obj-m := $(MODULE_NAME).o -all: - make -C $(INCLUDE_DIR) M=$(PWD) modules +MOD_KERNEL_PATH := /kernel/drivers/net + +default: module + +module: + $(MAKE) -C $(KDIR) M=$(PWD) modules clean: - make -C $(INCLUDE_DIR) M=$(PWD) clean + $(MAKE) -C $(KDIR) M=$(PWD) clean install: + $(MAKE) -C $(KDIR) M=$$PWD INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=$(MOD_KERNEL_PATH) modules_install modprobe udp_tunnel - cp $(MODULE_NAME).ko /lib/modules/`uname -r`/kernel/drivers/net - depmod -a + $(DEPMOD) modprobe $(MODULE_NAME) echo "gtp5g" >> /etc/modules uninstall: - rmmod $(MODULE_NAME) - rm -f /lib/modules/`uname -r`/kernel/drivers/net/$(MODULE_NAME).ko - depmod -a + rm -f $(DESTDIR)/lib/modules/$(KVER)/$(MOD_KERNEL_PATH)/$(MODULE_NAME).ko + $(DEPMOD) sed -zi "s/gtp5g\n//g" /etc/modules + rmmod -f $(MODULE_NAME) diff --git a/README.md b/README.md index 333de03..aa0e2b0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ For detailed information, please reference to 3GPP specification TS 29.281 and T ## Notice Due to the evolution of Linux kernel, this module would not work with every kernel version. -Please run this module with kernel version `5.0.0-23-generic` or upper than `5.4` (Ubuntu 20.04). +Please run this module with kernel version `5.0.0-23-generic`, upper than `5.4` (Ubuntu 20.04) or RHEL8. Please check the [libgtp5gnl](https://github.com/free5gc/libgtp5gnl) version is the same as gtp5g, because the type translating between libgtp5gnl and gtp5g had been changed. @@ -41,6 +41,8 @@ The gtp5g interface will be created by using libgtp5gnl scripts + Note: It will delete list of rules and interface ## Change Log +### v0.2.1 ++ Support for RHEL8 ### v0.2.0 + Changed to host type between gtp5g and libgtp5gnl + Supported forwarding policy feature, but need to set ip rule and ip route with Linux mark by self diff --git a/gtp5g.c b/gtp5g.c index 0b96f6d..2290ba9 100644 --- a/gtp5g.c +++ b/gtp5g.c @@ -1184,7 +1184,7 @@ static struct rtable *ip4_find_route(struct sk_buff *skb, struct iphdr *iph, mtu = dst_mtu(&rt->dst); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) || defined(RHEL8) rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu, false); #else rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu);