All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] at/cdma/ifxmodem: Use /dev/net/tun to check for TUN support
@ 2017-08-22 16:16 Matthijs Kooijman
  2017-08-23  4:26 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: Matthijs Kooijman @ 2017-08-22 16:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]

Previously, these drivers would check /sys/devices/virtual/misc/tun to
see if TUN is supported, and bail out otherwise. However, the tun module
can sometimes be autoloaded by opening the /dev/net/tun file. In this
case the /dev file already exists, but the /sys file only gets created
after the modul is loaded.

Additionally, the ppp code does not use the /sys file, but only the
/dev file, so checking for the existence of the latter seems a better
indicator of expected success.

---
This patch was only tested with the atmodem driver, but the other two
seem similar enough that it should work there as well.

This is a verbatim resend of this patch, orginally sent on 15th of July,
as requested by Denis Kenzior.
---
 drivers/atmodem/gprs-context.c  | 4 ++--
 drivers/cdmamodem/connman.c     | 4 ++--
 drivers/ifxmodem/gprs-context.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index 9b9679e8..42ec556d 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -43,7 +43,7 @@
 #include "atmodem.h"
 #include "vendor.h"
 
-#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+#define TUN_DEV "/dev/net/tun"
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
@@ -426,7 +426,7 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
 
 	DBG("");
 
-	if (stat(TUN_SYSFS_DIR, &st) < 0) {
+	if (stat(TUN_DEV, &st) < 0) {
 		ofono_error("Missing support for TUN/TAP devices");
 		return -ENODEV;
 	}
diff --git a/drivers/cdmamodem/connman.c b/drivers/cdmamodem/connman.c
index 8c3265a1..7f0f54b6 100644
--- a/drivers/cdmamodem/connman.c
+++ b/drivers/cdmamodem/connman.c
@@ -43,7 +43,7 @@
 #include "cdmamodem.h"
 #include "drivers/atmodem/vendor.h"
 
-#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+#define TUN_DEV "/dev/net/tun"
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
@@ -285,7 +285,7 @@ static int cdma_connman_probe(struct ofono_cdma_connman *cm,
 
 	DBG("");
 
-	if (stat(TUN_SYSFS_DIR, &st) < 0) {
+	if (stat(TUN_DEV, &st) < 0) {
 		ofono_error("Missing support for TUN/TAP devices");
 		return -ENODEV;
 	}
diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c
index b7b102b9..52a3672c 100644
--- a/drivers/ifxmodem/gprs-context.c
+++ b/drivers/ifxmodem/gprs-context.c
@@ -42,7 +42,7 @@
 
 #include "ifxmodem.h"
 
-#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+#define TUN_DEV "/dev/net/tun"
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
@@ -470,7 +470,7 @@ static int ifx_gprs_context_probe(struct ofono_gprs_context *gc,
 
 	DBG("");
 
-	if (stat(TUN_SYSFS_DIR, &st) < 0) {
+	if (stat(TUN_DEV, &st) < 0) {
 		ofono_error("Missing support for TUN/TAP devices");
 		return -ENODEV;
 	}
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] at/cdma/ifxmodem: Use /dev/net/tun to check for TUN support
  2017-08-22 16:16 [PATCH] at/cdma/ifxmodem: Use /dev/net/tun to check for TUN support Matthijs Kooijman
@ 2017-08-23  4:26 ` Denis Kenzior
  0 siblings, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2017-08-23  4:26 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

Hi Matthijs,

On 08/22/2017 11:16 AM, Matthijs Kooijman wrote:
> Previously, these drivers would check /sys/devices/virtual/misc/tun to
> see if TUN is supported, and bail out otherwise. However, the tun module
> can sometimes be autoloaded by opening the /dev/net/tun file. In this
> case the /dev file already exists, but the /sys file only gets created
> after the modul is loaded.
> 
> Additionally, the ppp code does not use the /sys file, but only the
> /dev file, so checking for the existence of the latter seems a better
> indicator of expected success.
> 
> ---
> This patch was only tested with the atmodem driver, but the other two
> seem similar enough that it should work there as well.
> 
> This is a verbatim resend of this patch, orginally sent on 15th of July,
> as requested by Denis Kenzior.

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] at/cdma/ifxmodem: Use /dev/net/tun to check for TUN support
@ 2017-07-15 12:09 Matthijs Kooijman
  0 siblings, 0 replies; 3+ messages in thread
From: Matthijs Kooijman @ 2017-07-15 12:09 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2770 bytes --]

Previously, these drivers would check /sys/devices/virtual/misc/tun to
see if TUN is supported, and bail out otherwise. However, the tun module
can sometimes be autoloaded by opening the /dev/net/tun file. In this
case the /dev file already exists, but the /sys file only gets created
after the modul is loaded.

Additionally, the ppp code does not use the /sys file, but only the
/dev file, so checking for the existence of the latter seems a better
indicator of expected success.

---
This patch was only tested with the atmodem driver, but the other two
seem similar enough that it should work there as well.
---
 drivers/atmodem/gprs-context.c  | 4 ++--
 drivers/cdmamodem/connman.c     | 4 ++--
 drivers/ifxmodem/gprs-context.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index 9b9679e8..42ec556d 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -43,7 +43,7 @@
 #include "atmodem.h"
 #include "vendor.h"
 
-#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+#define TUN_DEV "/dev/net/tun"
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
@@ -426,7 +426,7 @@ static int at_gprs_context_probe(struct ofono_gprs_context *gc,
 
 	DBG("");
 
-	if (stat(TUN_SYSFS_DIR, &st) < 0) {
+	if (stat(TUN_DEV, &st) < 0) {
 		ofono_error("Missing support for TUN/TAP devices");
 		return -ENODEV;
 	}
diff --git a/drivers/cdmamodem/connman.c b/drivers/cdmamodem/connman.c
index 8c3265a1..7f0f54b6 100644
--- a/drivers/cdmamodem/connman.c
+++ b/drivers/cdmamodem/connman.c
@@ -43,7 +43,7 @@
 #include "cdmamodem.h"
 #include "drivers/atmodem/vendor.h"
 
-#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+#define TUN_DEV "/dev/net/tun"
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
@@ -285,7 +285,7 @@ static int cdma_connman_probe(struct ofono_cdma_connman *cm,
 
 	DBG("");
 
-	if (stat(TUN_SYSFS_DIR, &st) < 0) {
+	if (stat(TUN_DEV, &st) < 0) {
 		ofono_error("Missing support for TUN/TAP devices");
 		return -ENODEV;
 	}
diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c
index b7b102b9..52a3672c 100644
--- a/drivers/ifxmodem/gprs-context.c
+++ b/drivers/ifxmodem/gprs-context.c
@@ -42,7 +42,7 @@
 
 #include "ifxmodem.h"
 
-#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+#define TUN_DEV "/dev/net/tun"
 
 #define STATIC_IP_NETMASK "255.255.255.255"
 
@@ -470,7 +470,7 @@ static int ifx_gprs_context_probe(struct ofono_gprs_context *gc,
 
 	DBG("");
 
-	if (stat(TUN_SYSFS_DIR, &st) < 0) {
+	if (stat(TUN_DEV, &st) < 0) {
 		ofono_error("Missing support for TUN/TAP devices");
 		return -ENODEV;
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-23  4:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-22 16:16 [PATCH] at/cdma/ifxmodem: Use /dev/net/tun to check for TUN support Matthijs Kooijman
2017-08-23  4:26 ` Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2017-07-15 12:09 Matthijs Kooijman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.