[MERGED] osmo-ggsn[master]: lib/tun.c: Generalize tun_sifflags() to netdev_sifflags

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Apr 25 19:45:11 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: lib/tun.c: Generalize tun_sifflags() to netdev_sifflags
......................................................................


lib/tun.c: Generalize tun_sifflags() to netdev_sifflags

There's nothing "tun" specific about that function, let's clarify that.

Change-Id: Iae7ced700245d6c1ac7e9807ab80d12fde8da116
---
M lib/tun.c
1 file changed, 7 insertions(+), 7 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/lib/tun.c b/lib/tun.c
index f6d3503..d6ca24e 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -1,7 +1,7 @@
 /*
  * TUN interface functions.
  * Copyright (C) 2002, 2003, 2004 Mondru AB.
- * Copyright (C) 2017 by Harald Welte <laforge at gnumonks.org>
+ * Copyright (C) 2017-2018 by Harald Welte <laforge at gnumonks.org>
  *
  * The contents of this file may be used under the terms of the GNU
  * General Public License Version 2, provided that the above copyright
@@ -79,14 +79,14 @@
 }
 #endif
 
-static int tun_sifflags(struct tun_t *this, int flags)
+static int netdev_sifflags(const char *devname, int flags)
 {
 	struct ifreq ifr;
 	int fd;
 
 	memset(&ifr, '\0', sizeof(ifr));
 	ifr.ifr_flags = flags;
-	strncpy(ifr.ifr_name, this->devname, IFNAMSIZ);
+	strncpy(ifr.ifr_name, devname, IFNAMSIZ);
 	ifr.ifr_name[IFNAMSIZ - 1] = 0;	/* Make sure to terminate */
 	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
 		SYS_ERR(DTUN, LOGL_ERROR, errno, "socket() failed");
@@ -187,7 +187,7 @@
 
 	/* TODO: How does it work on Solaris? */
 
-	tun_sifflags(this, IFF_UP | IFF_RUNNING);
+	netdev_sifflags(this->devname, IFF_UP | IFF_RUNNING);
 
 #if defined(__FreeBSD__) || defined (__APPLE__)
 	tun_addroute(this, dstaddr, addr, &this->netmask);
@@ -270,7 +270,7 @@
 
 	/* TODO: How does it work on Solaris? */
 
-	tun_sifflags(this, IFF_UP | IFF_RUNNING);
+	netdev_sifflags(this->devname, IFF_UP | IFF_RUNNING);
 
 #if 0	/* FIXME */
 //#if defined(__FreeBSD__) || defined (__APPLE__)
@@ -400,7 +400,7 @@
 		return -1;
 	}
 
-	status = tun_sifflags(this, IFF_UP | IFF_RUNNING);
+	status = netdev_sifflags(this->devname, IFF_UP | IFF_RUNNING);
 	if (status == -1) {
 		close(fd);
 		return -1;
@@ -570,7 +570,7 @@
 		return -1;
 	}
 
-	status = tun_sifflags(this, IFF_UP | IFF_RUNNING);
+	status = netdev_sifflags(this->devname, IFF_UP | IFF_RUNNING);
 	if (status == -1) {
 		close(fd);
 		return -1;

-- 
To view, visit https://gerrit.osmocom.org/7920
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iae7ced700245d6c1ac7e9807ab80d12fde8da116
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list