Add support for SGSN role via IFLA_GTP_ROLE

This patch corresponds to a Linux kernel patch extending the kernel GTP
to also cover the SGSN role, not just the GGSN role.  In order to keep
the API/behavior compatible, gtp_dev_create() will continue to create
GGSN-side tunnels, while a new gtp_dev_create_sgsn() is introduced to
create SGSN-side tunnels.

Signed-off-by: Harald Welte <laforge@gnumonks.org>
This commit is contained in:
Harald Welte 2017-03-15 18:03:42 +01:00
parent e17988ac7b
commit 6d60a402b2
3 changed files with 21 additions and 1 deletions

View File

@ -17,6 +17,7 @@ int genl_lookup_family(struct mnl_socket *nl, const char *family);
struct in_addr;
int gtp_dev_create(int dest_ns, const char *gtp_ifname, int fd0, int fd1);
int gtp_dev_create_sgsn(int dest_ns, const char *gtp_ifname, int fd0, int fd1);
int gtp_dev_config(const char *iface, struct in_addr *net, uint32_t prefix);
int gtp_dev_destroy(const char *gtp_ifname);

View File

@ -518,11 +518,18 @@ enum {
#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
/* GTP section */
enum ifla_gtp_role {
GTP_ROLE_GGSN = 0,
GTP_ROLE_SGSN,
};
enum {
IFLA_GTP_UNSPEC,
IFLA_GTP_FD0,
IFLA_GTP_FD1,
IFLA_GTP_PDP_HASHSIZE,
IFLA_GTP_ROLE,
__IFLA_GTP_MAX,
};
#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)

View File

@ -105,7 +105,8 @@ static int gtp_dev_talk(struct nlmsghdr *nlh, uint32_t seq)
return ret;
}
int gtp_dev_create(int dest_ns, const char *gtp_ifname, int fd0, int fd1)
static int _gtp_dev_create(int dest_ns, const char *gtp_ifname, int fd0,
int fd1, enum ifla_gtp_role role)
{
char buf[MNL_SOCKET_BUFFER_SIZE];
struct nlmsghdr *nlh;
@ -134,8 +135,19 @@ int gtp_dev_create(int dest_ns, const char *gtp_ifname, int fd0, int fd1)
return gtp_dev_talk(nlh, seq);
}
int gtp_dev_create(int dest_ns, const char *gtp_ifname, int fd0, int fd1)
{
return _gtp_dev_create(dest_ns, gtp_ifname, fd0, fd1, GTP_ROLE_GGSN);
}
EXPORT_SYMBOL(gtp_dev_create);
int gtp_dev_create_sgsn(int dest_ns, const char *gtp_ifname, int fd0, int fd1)
{
return _gtp_dev_create(dest_ns, gtp_ifname, fd0, fd1, GTP_ROLE_SGSN);
}
EXPORT_SYMBOL(gtp_dev_create_sgsn);
int gtp_dev_destroy(const char *gtp_ifname)
{
char buf[MNL_SOCKET_BUFFER_SIZE];