gtp-rtnl: add gtp_dev_destroy

This function allows you to destroy the gtpX device.
This commit is contained in:
Pablo Neira Ayuso 2014-02-22 23:07:41 +01:00
parent b94023299f
commit 1afa16a16b
3 changed files with 22 additions and 0 deletions

View File

@ -15,6 +15,7 @@ int genl_socket_talk(struct mnl_socket *nl, struct nlmsghdr *nlh, uint32_t seq,
int genl_lookup_family(struct mnl_socket *nl, const char *family);
int gtp_dev_create(const char *ifname);
int gtp_dev_destroy(const char *ifname);
struct gtp_tunnel;

View File

@ -98,3 +98,21 @@ int gtp_dev_create(const char *ifname)
return gtp_dev_talk(nlh, seq);
}
EXPORT_SYMBOL(gtp_dev_create);
int gtp_dev_destroy(const char *ifname)
{
char buf[MNL_SOCKET_BUFFER_SIZE];
struct nlmsghdr *nlh;
struct ifinfomsg *ifm;
unsigned int seq = time(NULL);
nlh = gtp_put_nlmsg(buf, RTM_DELLINK, NLM_F_ACK, seq);
ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm));
ifm->ifi_family = AF_INET;
ifm->ifi_change |= IFF_UP;
ifm->ifi_flags &= ~IFF_UP;
ifm->ifi_index = if_nametoindex(ifname);
return gtp_dev_talk(nlh, seq);
}
EXPORT_SYMBOL(gtp_dev_destroy);

View File

@ -4,7 +4,10 @@ global:
genl_nlmsg_build_hdr;
genl_socket_talk;
genl_lookup_family;
gtp_dev_create;
gtp_dev_destroy;
gtp_add_tunnel;
gtp_del_tunnel;
gtp_list_tunnel;