summaryrefslogtreecommitdiff
path: root/accel-pppd/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/net.c')
-rw-r--r--accel-pppd/net.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/accel-pppd/net.c b/accel-pppd/net.c
index e5cf2818..9a025ed3 100644
--- a/accel-pppd/net.c
+++ b/accel-pppd/net.c
@@ -7,6 +7,7 @@
#include <sched.h>
#include <limits.h>
#include <errno.h>
+#include <linux/if.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
@@ -215,6 +216,22 @@ static int def_move_link(struct ap_net *new_net, int ifindex)
#endif
}
+static int def_get_ifindex(const char *ifname)
+{
+ struct kern_net *n = container_of(net, typeof(*n), net);
+ struct ifreq ifr;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strcpy(ifr.ifr_name, ifname);
+
+ if (ioctl(n->sock, SIOCGIFINDEX, &ifr)) {
+ log_ppp_error("ioctl(SIOCGIFINDEX): %s\n", strerror(errno));
+ return -1;
+ }
+ return ifr.ifr_ifindex;
+}
+
+
static void def_release(struct ap_net *d)
{
struct kern_net *n = container_of(d, typeof(*n), net);
@@ -299,6 +316,7 @@ static struct ap_net *alloc_net(const char *name)
net->rtnl_put = def_rtnl_put;
net->rtnl_open = def_rtnl_open;
net->move_link = def_move_link;
+ net->get_ifindex = def_get_ifindex;
net->release = def_release;
n->sock = socket(AF_INET, SOCK_DGRAM, 0);