From a12460e88242841c6449b713942828635c6a7fb1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt <robert.schmidt@openairinterface.org> Date: Thu, 6 Jun 2024 20:08:35 +0200 Subject: [PATCH] nas_config_mbms/netlink_init_mbms_tun(): use entire interface prefix Does the same change in the _mbms() functions as in the previous commit. Also, simplify logic in netlink_init_mbms_tun(): directly use the id in the interface. This requires a slight ID change in the users, which is also done in this commit. --- .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 17 ++++++----------- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 12 ++++++------ openair2/RRC/NAS/nas_config.c | 6 +++--- openair2/RRC/NAS/nas_config.h | 2 +- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index 919edbb8349..e32cb81b005 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -93,24 +93,19 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ..., int ret; char ifname[64]; - if (id > 0) { - sprintf(ifname, "oaitun_%.3s%d", ifprefix, id-1); - } - else { - sprintf(ifname, "oaitun_%.3s1", ifprefix); // added "1": for historical reasons - } - nas_sock_mbms_fd = tun_alloc(ifname); + sprintf(ifname, "%s%d", ifprefix, id); + nas_sock_mbms_fd = tun_alloc(ifname); - if (nas_sock_mbms_fd == -1) { - printf("[NETLINK] Error opening mbms socket %s (%d:%s)\n",ifname,errno, strerror(errno)); - exit(1); + if (nas_sock_mbms_fd == -1) { + LOG_E(PDCP, "[NETLINK] Error opening mbms socket %s (%d:%s)\n", ifname, errno, strerror(errno)); + exit(1); } printf("[NETLINK]Opened socket %s with fd %d\n",ifname,nas_sock_mbms_fd); ret = fcntl(nas_sock_mbms_fd,F_SETFL,O_NONBLOCK); if (ret == -1) { - printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); + LOG_E(PDCP, "[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); if (LINK_ENB_PDCP_TO_IP_DRIVER) { exit(1); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 33ecfe0c0c3..15dc9a24031 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -2303,21 +2303,21 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) { netlink_init_tun("oaitun_ue", num_if, id); if (IS_SOFTMODEM_NOS1) nas_config(1, 1, 2, "oaitun_ue"); - netlink_init_mbms_tun("uem", id); - nas_config_mbms(1, 2, 2, "uem"); + netlink_init_mbms_tun("oaitun_uem", id + 1); + nas_config_mbms(1, 2, 2, "oaitun_uem"); LOG_I(PDCP, "UE pdcp will use tun interface\n"); } else if (ENB_NAS_USE_TUN) { netlink_init_tun("oaitun_enb", 1, 0); nas_config(1, 1, 1, "oaitun_enb"); if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { - netlink_init_mbms_tun("enm", 0); - nas_config_mbms(1, 2, 1, "enm"); + netlink_init_mbms_tun("oaitun_enm", 1); + nas_config_mbms(1, 2, 1, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } LOG_I(PDCP, "ENB pdcp will use tun interface\n"); } else if (pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT) { - netlink_init_mbms_tun("enm", 0); - nas_config_mbms(1, 2, 1, "enm"); + netlink_init_mbms_tun("oaitun_enm", 0); + nas_config_mbms(1, 2, 1, "oaitun_enm"); LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n"); } diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index d3618483ba3..087d3c81a0d 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -149,7 +149,8 @@ static int bringInterfaceUp(char *interfaceName, int up) return 0; } -int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifname) { +int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, const char *ifname) +{ //char buf[5]; char ipAddress[20]; char broadcastAddress[20]; @@ -161,8 +162,7 @@ int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifn sprintf(ipAddress, "%s.%d.%d",baseNetAddress,thirdOctet,fourthOctet); sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet); - sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname, - UE_NAS_USE_TUN?ifname/*"ue"*/: (ENB_NAS_USE_TUN?ifname/*"enb"*/:""),interface_id); + sprintf(interfaceName, "%s%d", ifname, interface_id); bringInterfaceUp(interfaceName, 0); // sets the machine address returnValue= setInterfaceParameter(interfaceName, ipAddress,SIOCSIFADDR); diff --git a/openair2/RRC/NAS/nas_config.h b/openair2/RRC/NAS/nas_config.h index 72a3bc68874..017bf57133d 100644 --- a/openair2/RRC/NAS/nas_config.h +++ b/openair2/RRC/NAS/nas_config.h @@ -62,7 +62,7 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, const char *if * \note * @ingroup _nas */ -int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, char *ifsuffix); +int nas_config_mbms(int interface_id, int thirdOctet, int fourthOctet, const char *ifname); /*! \fn void setBaseNetAddress(char*) * \brief This function sets the basic network address used -- GitLab