summaryrefslogtreecommitdiff
path: root/accel-pppd/session.c
diff options
context:
space:
mode:
authorSimon Chopin <s.chopin@alphalink.fr>2020-02-28 11:28:07 +0100
committerSimon Chopin <s.chopin@alphalink.fr>2020-03-18 09:07:38 +0100
commitf5b1c3f98bf082d4ecf57e8f2e3c61fc993d80e7 (patch)
tree060169e9c70a15cc083d4efbbe52a9537264dfd3 /accel-pppd/session.c
parent7afe0f075676219ab4b9e8dbfed294992e9f360b (diff)
downloadaccel-ppp-f5b1c3f98bf082d4ecf57e8f2e3c61fc993d80e7.tar.gz
accel-ppp-f5b1c3f98bf082d4ecf57e8f2e3c61fc993d80e7.zip
net: new function get_ifindex
The index of a given interface is an operation that highly depends on the network namespace we're in. This patch simply cuts out a function to get the index for a given interface name from the session initialization code, and expose it in the ap_net structure. This function can then be used to refresh the index when moving interfaces around. Signed-off-by: Simon Chopin <s.chopin@alphalink.fr>
Diffstat (limited to 'accel-pppd/session.c')
-rw-r--r--accel-pppd/session.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/accel-pppd/session.c b/accel-pppd/session.c
index 8ef569e..1411f24 100644
--- a/accel-pppd/session.c
+++ b/accel-pppd/session.c
@@ -88,21 +88,11 @@ void __export ap_session_set_ifindex(struct ap_session *ses)
int __export ap_session_starting(struct ap_session *ses)
{
- struct ifreq ifr;
-
if (ap_shutdown)
return -1;
- if (ses->ifindex == -1 && ses->ifname[0]) {
- memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, ses->ifname);
-
- if (net->sock_ioctl(SIOCGIFINDEX, &ifr)) {
- log_ppp_error("ioctl(SIOCGIFINDEX): %s\n", strerror(errno));
- return -1;
- }
- ses->ifindex = ifr.ifr_ifindex;
- }
+ if (ses->ifindex == -1 && ses->ifname[0])
+ ses->ifindex = net->get_ifindex(ses->ifname);
if (ses->ifindex != -1)
ap_session_set_ifindex(ses);