gtp-genl: display gtp device in listing

Display the device that the tunnel belongs to, users need this
information to delete tunnels.

Change-Id: I888723a8318c04772f7d22a042e69fa6e9ef2239
This commit is contained in:
Pablo Neira Ayuso 2024-01-31 13:08:58 +01:00 committed by Oliver Smith
parent 6f1c38fc6a
commit aac20a7771
1 changed files with 6 additions and 0 deletions

View File

@ -141,6 +141,7 @@ int gtp_del_tunnel(int genl_id, struct mnl_socket *nl, struct gtp_tunnel *t)
EXPORT_SYMBOL(gtp_del_tunnel);
struct gtp_pdp {
uint32_t ifidx;
uint32_t version;
union {
struct {
@ -181,6 +182,7 @@ static int genl_gtp_validate_cb(const struct nlattr *attr, void *data)
case GTPA_PEER_ADDRESS:
case GTPA_MS_ADDRESS:
case GTPA_VERSION:
case GTPA_LINK:
if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) {
perror("mnl_attr_validate");
return MNL_CB_ERROR;
@ -210,6 +212,8 @@ static int genl_gtp_attr_cb(const struct nlmsghdr *nlh, void *data)
mnl_attr_parse(nlh, sizeof(*genl), genl_gtp_validate_cb, tb);
if (tb[GTPA_LINK])
pdp.ifidx = mnl_attr_get_u32(tb[GTPA_LINK]);
if (tb[GTPA_TID])
pdp.u.v0.tid = mnl_attr_get_u64(tb[GTPA_TID]);
if (tb[GTPA_I_TEI])
@ -245,6 +249,8 @@ static int genl_gtp_attr_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_ERROR;
}
printf("%s ", if_indextoname(pdp.ifidx, buf));
if (tb[GTPA_VERSION])
pdp.version = mnl_attr_get_u32(tb[GTPA_VERSION]);