Adding ability to configure names of TUN interfaces. (#277)

* added config option for tun dev names vs fixed names added config option for M1-U interface addr

* Added options to sgi_mb tun name.

* Added some comments to mbms.conf.example

* Added some comments to example configs to explain the new values.
master
Pedro Alvarez 6 years ago committed by Andre Puschmann
parent 35ca9ffd34
commit 3cddad79cc

@ -40,13 +40,16 @@ db_file = user_db.csv
#####################################################################
# SP-GW configuration
#
# gtpu_bind_addr: GTP-U bind adress.
# gtpu_bind_addr: GTP-U bind address.
# sgi_if_addr: SGi TUN interface IP address.
# sgi_if_name: SGi TUN interface name.
#
#####################################################################
[spgw]
gtpu_bind_addr = 127.0.1.100
sgi_if_addr = 172.16.0.1
sgi_if_name = srs_spgw_sgi
####################################################################
# PCAP configuration

@ -48,6 +48,7 @@ const uint16_t GTPU_RX_PORT = 2152;
typedef struct {
std::string name;
std::string sgi_mb_if_name;
std::string sgi_mb_if_addr;
std::string sgi_mb_if_mask;
std::string m1u_multi_addr;

@ -50,6 +50,7 @@ const uint16_t GTPU_RX_PORT = 2152;
typedef struct {
std::string gtpu_bind_addr;
std::string sgi_if_addr;
std::string sgi_if_name;
} spgw_args_t;

@ -1,17 +1,22 @@
#####################################################################
# srsEPC configuration file
# srsMBMS configuration file
#####################################################################
#####################################################################
# MBMS-GW configuration
#
# name: MBMS-GW name
# sgi_mb_if_name: SGi-mb TUN interface name
# sgi_mb_if_addr: SGi-mb interface IP address
# m1u_addr: Multicast group for eNBs (FIXME this should be setup with M2/M3)
# sgi_mb_if_mask: SGi-mb interface IP mask
# m1u_multi_addr: Multicast group for eNBs (FIXME this should be setup with M2/M3)
# m1u_multi_if: IP of local interface for multicast traffic
# m1u_multi_ttl: TTL for M1-U multicast traffic
#
#####################################################################
[mbms_gw]
name = srsmbmsgw01
sgi_mb_if_name = sgi_mb
sgi_mb_if_addr = 172.16.0.254
sgi_mb_if_mask = 255.255.255.255
m1u_multi_addr = 239.255.0.1

@ -87,6 +87,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
string mme_apn;
string spgw_bind_addr;
string sgi_if_addr;
string sgi_if_name;
string dns_addr;
string hss_db_file;
string hss_auth_algo;
@ -116,6 +117,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
("hss.auth_algo", bpo::value<string>(&hss_auth_algo)->default_value("milenage"), "HSS uthentication algorithm.")
("spgw.gtpu_bind_addr", bpo::value<string>(&spgw_bind_addr)->default_value("127.0.0.1"), "IP address of SP-GW for the S1-U connection")
("spgw.sgi_if_addr", bpo::value<string>(&sgi_if_addr)->default_value("176.16.0.1"), "IP address of TUN interface for the SGi connection")
("spgw.sgi_if_name", bpo::value<string>(&sgi_if_name)->default_value("srs_spgw_sgi"), "Name of TUN interface for the SGi connection")
("pcap.enable", bpo::value<bool>(&args->mme_args.s1ap_args.pcap_enable)->default_value(false), "Enable S1AP PCAP")
("pcap.filename", bpo::value<string>(&args->mme_args.s1ap_args.pcap_filename)->default_value("/tmp/epc.pcap"), "PCAP filename")
@ -219,6 +221,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
args->mme_args.s1ap_args.mme_apn = mme_apn;
args->spgw_args.gtpu_bind_addr = spgw_bind_addr;
args->spgw_args.sgi_if_addr = sgi_if_addr;
args->spgw_args.sgi_if_name = sgi_if_name;
args->hss_args.db_file = hss_db_file;
args->hss_args.auth_algo = hss_auth_algo;

@ -82,6 +82,7 @@ void
parse_args(all_args_t *args, int argc, char* argv[]) {
string mbms_gw_name;
string mbms_gw_sgi_mb_if_name;
string mbms_gw_sgi_mb_if_addr;
string mbms_gw_sgi_mb_if_mask;
string mbms_gw_m1u_multi_addr;
@ -101,6 +102,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
common.add_options()
("mbms_gw.name", bpo::value<string>(&mbms_gw_name)->default_value("srsmbmsgw01"), "MBMS-GW Name")
("mbms_gw.sgi_mb_if_name", bpo::value<string>(&mbms_gw_sgi_mb_if_name)->default_value("sgi_mb"), "SGi-mb TUN interface Address.")
("mbms_gw.sgi_mb_if_addr", bpo::value<string>(&mbms_gw_sgi_mb_if_addr)->default_value("172.16.1.1"), "SGi-mb TUN interface Address.")
("mbms_gw.sgi_mb_if_mask", bpo::value<string>(&mbms_gw_sgi_mb_if_mask)->default_value("255.255.255.255"), "SGi-mb TUN interface mask.")
("mbms_gw.m1u_multi_addr", bpo::value<string>(&mbms_gw_m1u_multi_addr)->default_value("239.255.0.1"), "M1-u GTPu destination multicast address.")
@ -156,6 +158,7 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
bpo::notify(vm);
args->mbms_gw_args.name = mbms_gw_name;
args->mbms_gw_args.sgi_mb_if_name = mbms_gw_sgi_mb_if_name;
args->mbms_gw_args.sgi_mb_if_addr = mbms_gw_sgi_mb_if_addr;
args->mbms_gw_args.sgi_mb_if_mask = mbms_gw_sgi_mb_if_mask;
args->mbms_gw_args.m1u_multi_addr = mbms_gw_m1u_multi_addr;

@ -126,7 +126,6 @@ mbms_gw::stop()
srslte::error_t
mbms_gw::init_sgi_mb_if(mbms_gw_args_t *args)
{
char dev[IFNAMSIZ] = "sgi_mb";
struct ifreq ifr;
if(m_sgi_mb_up)
@ -138,22 +137,22 @@ mbms_gw::init_sgi_mb_if(mbms_gw_args_t *args)
// Construct the TUN device
m_sgi_mb_if = open("/dev/net/tun", O_RDWR);
m_mbms_gw_log->info("TUN file descriptor = %d\n", m_sgi_mb_if);
if(m_sgi_mb_if < 0)
{
if (m_sgi_mb_if < 0) {
m_mbms_gw_log->error("Failed to open TUN device: %s\n", strerror(errno));
return(srslte::ERROR_CANT_START);
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ-1);
strncpy(ifr.ifr_ifrn.ifrn_name, args->sgi_mb_if_name.c_str(), std::min(args->sgi_mb_if_name.length(), (size_t)IFNAMSIZ-1) );
ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0';
if(ioctl(m_sgi_mb_if, TUNSETIFF, &ifr) < 0)
{
m_mbms_gw_log->error("Failed to set TUN device name: %s\n", strerror(errno));
close(m_sgi_mb_if);
return(srslte::ERROR_CANT_START);
if (ioctl(m_sgi_mb_if, TUNSETIFF, &ifr) < 0) {
m_mbms_gw_log->error("Failed to set TUN device name: %s\n", strerror(errno));
close(m_sgi_mb_if);
return(srslte::ERROR_CANT_START);
} else {
m_mbms_gw_log->debug("Set TUN device name: %s\n", args->sgi_mb_if_name.c_str());
}
// Bring up the interface
@ -236,7 +235,8 @@ mbms_gw::init_m1_u(mbms_gw_args_t *args)
struct in_addr local_if;
local_if.s_addr = inet_addr(args->m1u_multi_if.c_str());
if(setsockopt(m_m1u, IPPROTO_IP, IP_MULTICAST_IF, (char*)&local_if, sizeof(struct in_addr))<0){
perror("Error setting multicast interface.\n");
m_mbms_gw_log->error("Error %s setting multicast interface %s.\n", strerror(errno), args->m1u_multi_if.c_str());
return srslte::ERROR_CANT_START;
} else {
printf("Multicast interface specified. Address: %s\n", args->m1u_multi_if.c_str());
}

@ -157,7 +157,6 @@ spgw::stop()
srslte::error_t
spgw::init_sgi_if(spgw_args_t *args)
{
char dev[IFNAMSIZ] = "srs_spgw_sgi";
struct ifreq ifr;
if(m_sgi_up)
@ -177,7 +176,7 @@ spgw::init_sgi_if(spgw_args_t *args)
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ-1);
strncpy(ifr.ifr_ifrn.ifrn_name, args->sgi_if_name.c_str(), std::min(args->sgi_if_name.length(), (size_t)(IFNAMSIZ-1)));
ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0';
if(ioctl(m_sgi_if, TUNSETIFF, &ifr) < 0)

@ -111,6 +111,7 @@ typedef struct {
typedef struct {
std::string ip_netmask;
std::string ip_devname;
phy_args_t phy;
float metrics_period_secs;
bool pregenerate_signals;

@ -52,6 +52,7 @@ public:
void get_metrics(gw_metrics_t &m);
void set_netmask(std::string netmask);
void set_tundevname(const std::string & devname);
// PDCP interface
void write_pdu(uint32_t lcid, srslte::byte_buffer_t *pdu);
@ -67,6 +68,7 @@ private:
bool default_netmask;
std::string netmask;
std::string tundevname;
static const int GW_THREAD_PRIO = 7;

@ -142,6 +142,10 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
bpo::value<string>(&args->expert.ip_netmask)->default_value("255.255.255.0"),
"Netmask of the tun_srsue device")
("expert.ip_devname",
bpo::value<string>(&args->expert.ip_devname)->default_value("tun_srsue"),
"Name of the tun_srsue device")
("expert.mbms_service",
bpo::value<int>(&args->expert.mbms_service)->default_value(-1),
"automatically starts an mbms service of the number given")

@ -225,6 +225,7 @@ bool ue::init(all_args_t *args_) {
nas.init(usim, &rrc, &gw, &nas_log, nas_cfg);
gw.init(&pdcp, &nas, &gw_log, 3 /* RB_ID_DRB1 */);
gw.set_netmask(args->expert.ip_netmask);
gw.set_tundevname(args->expert.ip_devname);
// Get current band from provided EARFCN
args->rrc.supported_bands[0] = srslte_band_get_band(args->rf.dl_earfcn);

@ -45,6 +45,7 @@ gw::gw()
{
current_ip_addr = 0;
default_netmask = true;
tundevname = "";
}
void gw::init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, srslte::srslte_gw_config_t cfg_)
@ -125,6 +126,11 @@ void gw::set_netmask(std::string netmask)
this->netmask = netmask;
}
void gw::set_tundevname(const std::string & devname)
{
tundevname = devname;
}
/*******************************************************************************
PDCP interface
@ -242,8 +248,6 @@ srslte::error_t gw::init_if(char *err_str)
return(srslte::ERROR_ALREADY_STARTED);
}
char dev[IFNAMSIZ] = "tun_srsue";
// Construct the TUN device
tun_fd = open("/dev/net/tun", O_RDWR);
gw_log->info("TUN file descriptor = %d\n", tun_fd);
@ -255,7 +259,7 @@ srslte::error_t gw::init_if(char *err_str)
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ-1);
strncpy(ifr.ifr_ifrn.ifrn_name, tundevname.c_str(), std::min(tundevname.length(), (size_t)(IFNAMSIZ-1)));
ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1] = 0;
if(0 > ioctl(tun_fd, TUNSETIFF, &ifr))
{

@ -137,6 +137,7 @@ enable = false
# Expert configuration options
#
# ip_netmask: Netmask of the tun_srsue device. Default: 255.255.255.0
# ip_devname: Nanme of the tun_srsue device. Default: tun_srsue
# rssi_sensor_enabled: Enable or disable RF frontend RSSI sensor. Required for RSRP metrics but
# can cause UHD instability for long-duration testing. Default true.
# rx_gain_offset: RX Gain offset to add to rx_gain to calibrate RSRP readings
@ -209,6 +210,7 @@ enable = false
#####################################################################
[expert]
#ip_netmask = 255.255.255.0
#ip_devname = tun_srsue
#mbms_service = -1
#rssi_sensor_enabled = false
#rx_gain_offset = 62

Loading…
Cancel
Save