Skip to content

Commit

Permalink
Support for RHEL8 (#10)
Browse files Browse the repository at this point in the history
* Support for RHEL8

* Enhanced Makefile for RHEL8

* Updated README.md

* Remove unused KVERSION variable from Makefile
  • Loading branch information
cdonatom authored Dec 24, 2021
1 parent c9d6679 commit 7848a9a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
45 changes: 34 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gtp5g.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7848a9a

Please sign in to comment.