[MERGED] osmo-ggsn[master]: lib/tun.c: generalize tun_*route() to netdev_*route()

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_*route() to netdev_*route()
......................................................................


lib/tun.c: generalize tun_*route() to netdev_*route()

There's nothing specific to tun devices in adding a route to the kernel.

Change-Id: Ib077934aa5f3c9bed06e2cf16a980c965a7a046d
---
M lib/tun.c
M lib/tun.h
M sgsnemu/sgsnemu.c
3 files changed, 10 insertions(+), 17 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/lib/tun.c b/lib/tun.c
index d6ca24e..14e4a58 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -274,7 +274,7 @@
 
 #if 0	/* FIXME */
 //#if defined(__FreeBSD__) || defined (__APPLE__)
-	tun_addroute6(this, dstaddr, addr, prefixlen);
+	netdev_addroute6(dstaddr, addr, prefixlen);
 	this->routes = 1;
 #endif
 
@@ -644,9 +644,7 @@
 	}
 }
 
-static int tun_route(struct tun_t *this,
-	      struct in_addr *dst,
-	      struct in_addr *gateway, struct in_addr *mask, int delete)
+static int netdev_route(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask, int delete)
 {
 
 #if defined(__linux__)
@@ -745,18 +743,14 @@
 
 }
 
-int tun_addroute(struct tun_t *this,
-		 struct in_addr *dst,
-		 struct in_addr *gateway, struct in_addr *mask)
+int netdev_addroute(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask)
 {
-	return tun_route(this, dst, gateway, mask, 0);
+	return netdev_route(dst, gateway, mask, 0);
 }
 
-int tun_delroute(struct tun_t *this,
-		 struct in_addr *dst,
-		 struct in_addr *gateway, struct in_addr *mask)
+int netdev_delroute(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask)
 {
-	return tun_route(this, dst, gateway, mask, 1);
+	return netdev_route(dst, gateway, mask, 1);
 }
 
 int tun_new(struct tun_t **tun, const char *dev_name)
@@ -858,7 +852,7 @@
 {
 
 	if (tun->routes) {
-		tun_delroute(tun, &tun->dstaddr, &tun->addr, &tun->netmask);
+		netdev_delroute(&tun->dstaddr, &tun->addr, &tun->netmask);
 	}
 
 	if (close(tun->fd)) {
diff --git a/lib/tun.h b/lib/tun.h
index 6f7c0ff..af9e9f4 100644
--- a/lib/tun.h
+++ b/lib/tun.h
@@ -86,8 +86,7 @@
 extern int tun_setaddr(struct tun_t *this, struct in46_addr *our_adr,
 		       struct in46_addr *his_adr, size_t prefixlen);
 
-int tun_addroute(struct tun_t *this, struct in_addr *dst,
-		 struct in_addr *gateway, struct in_addr *mask);
+int netdev_addroute(struct in_addr *dst, struct in_addr *gateway, struct in_addr *mask);
 
 extern int tun_set_cb_ind(struct tun_t *this,
 			  int (*cb_ind) (struct tun_t * tun, void *pack,
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index 99f56da..8903d81 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -1437,7 +1437,7 @@
 		if (options.defaultroute) {
 			struct in_addr rm;
 			rm.s_addr = 0;
-			tun_addroute(tun, &rm, &addr.v4, &rm);
+			netdev_addroute(&rm, &addr.v4, &rm);
 		}
 		if (options.ipup)
 			tun_runscript(tun, options.ipup);
@@ -1588,7 +1588,7 @@
 		if (options.defaultroute) {
 			struct in_addr rm;
 			rm.s_addr = 0;
-			tun_addroute(tun, &rm, &options.destaddr.v4, &rm);
+			netdev_addroute(&rm, &options.destaddr.v4, &rm);
 		}
 		if (options.ipup)
 			tun_runscript(tun, options.ipup);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib077934aa5f3c9bed06e2cf16a980c965a7a046d
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