From 1572aa01a2be328f604573c77f932e0a45cd03e3 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Sun, 31 Jan 2016 00:18:27 +0100 Subject: gisi: bring interface down on stop --- gisi/netlink.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gisi/netlink.c b/gisi/netlink.c index 816c481a..1893c2ca 100644 --- a/gisi/netlink.c +++ b/gisi/netlink.c @@ -79,7 +79,7 @@ struct _GIsiPhonetNetlink { static GSList *netlink_list; -static void bring_up(unsigned ifindex) +static void bring_up(unsigned ifindex, gboolean state) { struct ifreq req = { .ifr_ifindex = ifindex, }; int fd = socket(PF_LOCAL, SOCK_DGRAM, 0); @@ -88,7 +88,11 @@ static void bring_up(unsigned ifindex) || ioctl(fd, SIOCGIFFLAGS, &req)) goto error; - req.ifr_flags |= IFF_UP | IFF_RUNNING; + if(state) + req.ifr_flags |= IFF_UP | IFF_RUNNING; + else + req.ifr_flags &= ~(IFF_UP | IFF_RUNNING); + ioctl(fd, SIOCSIFFLAGS, &req); error: close(fd); @@ -270,7 +274,7 @@ GIsiPhonetNetlink *g_isi_pn_netlink_start(GIsiModem *modem, interface = g_isi_modem_index(modem); if (interface) - bring_up(interface); + bring_up(interface, TRUE); pn_netlink_getlink(fd); @@ -301,11 +305,18 @@ error: void g_isi_pn_netlink_stop(GIsiPhonetNetlink *self) { + unsigned interface; + if (self == NULL) return; netlink_list = g_slist_remove(netlink_list, self); g_source_remove(self->watch); + + interface = g_isi_modem_index(self->modem); + if (interface) + bring_up(interface, FALSE); + g_free(self); } -- cgit v1.2.3