From 1224565f750fe851b1efe004af73998536786410 Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <kallisti5@unixzen.com>
Date: Fri, 17 Nov 2023 17:14:21 -0600
Subject: [PATCH] tun: adjust tun device name to /dev/net/tun/0
* tun is just an interface essentially, so place it with
other network interfaces
Change-Id: Iadce8e498e4f147a085264cf2aed1a2d22b5d239
---
src/add-ons/kernel/drivers/network/tun/driver.cpp | 6 +++---
src/add-ons/kernel/network/devices/tun/tun.cpp | 6 +++++-
src/bin/network/ifconfig/ifconfig.cpp | 3 +++
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/add-ons/kernel/drivers/network/tun/driver.cpp b/src/add-ons/kernel/drivers/network/tun/driver.cpp
index f9fc33cbd4..0851b2fdc8 100644
a
|
b
|
|
25 | 25 | #include <util/AutoLock.h> |
26 | 26 | |
27 | 27 | |
28 | | // #define TUN_DRIVER_NAME "tun/0" |
29 | | #define TAP_DRIVER_NAME "tap/0" |
| 28 | #define TUN_DRIVER_NAME "net/tun/0" |
| 29 | #define TAP_DRIVER_NAME "net/tap/0" |
30 | 30 | #define NET_TUN_MODULE_NAME "network/devices/tun/v1" |
31 | 31 | #define BUFFER_QUEUE_MAX 30000 |
32 | 32 | |
33 | | const char* device_names[] = {TAP_DRIVER_NAME, NULL}; |
| 33 | const char* device_names[] = {TUN_DRIVER_NAME, /*TAP_DRIVER_NAME,*/ NULL}; |
34 | 34 | |
35 | 35 | typedef struct tun_struct { |
36 | 36 | uint32_t name[3]; |
diff --git a/src/add-ons/kernel/network/devices/tun/tun.cpp b/src/add-ons/kernel/network/devices/tun/tun.cpp
index 26bc065a44..0d64876c5e 100644
a
|
b
|
|
29 | 29 | #include <net/if_tun.h> |
30 | 30 | #include <net/if_types.h> |
31 | 31 | #include <new> |
| 32 | #include <stdio.h> |
32 | 33 | #include <stdlib.h> |
33 | 34 | #include <string.h> |
34 | 35 | #include <unistd.h> |
… |
… |
status_t
|
181 | 182 | tun_up(net_device* _device) |
182 | 183 | { |
183 | 184 | tun_device* device = (tun_device*)_device; |
184 | | device->fd = open("/dev/tap/0", O_RDWR); |
| 185 | char devicePath[32]; |
| 186 | |
| 187 | snprintf(devicePath, 32, "/dev/net/%s", device->name); |
| 188 | device->fd = open(devicePath, O_RDWR); |
185 | 189 | if (device->fd < 0) |
186 | 190 | return errno; |
187 | 191 | ioctl(device->fd, TUNSETIFF); |
diff --git a/src/bin/network/ifconfig/ifconfig.cpp b/src/bin/network/ifconfig/ifconfig.cpp
index 66e34ce48c..d019adf011 100644
a
|
b
|
list_interface(const char* name)
|
512 | 512 | if (status == B_OK) { |
513 | 513 | const char *type = "unknown"; |
514 | 514 | switch (linkAddress.LinkLevelType()) { |
| 515 | case IFT_TUN: |
| 516 | type = "Tunnel"; |
| 517 | break; |
515 | 518 | case IFT_ETHER: |
516 | 519 | type = "Ethernet"; |
517 | 520 | break; |