Ticket #18673: 0001-tun-adjust-tun-device-name-to-dev-net-tun-0.patch

File 0001-tun-adjust-tun-device-name-to-dev-net-tun-0.patch, 2.5 KB (added by kallisti5, 12 months ago)

haiku patches i was playing with, likely less useful

  • src/add-ons/kernel/drivers/network/tun/driver.cpp

    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  
    2525#include <util/AutoLock.h>
    2626
    2727
    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"
    3030#define NET_TUN_MODULE_NAME "network/devices/tun/v1"
    3131#define BUFFER_QUEUE_MAX 30000
    3232
    33 const char* device_names[] = {TAP_DRIVER_NAME, NULL};
     33const char* device_names[] = {TUN_DRIVER_NAME, /*TAP_DRIVER_NAME,*/ NULL};
    3434
    3535typedef struct tun_struct {
    3636    uint32_t           name[3];
  • src/add-ons/kernel/network/devices/tun/tun.cpp

    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  
    2929#include <net/if_tun.h>
    3030#include <net/if_types.h>
    3131#include <new>
     32#include <stdio.h>
    3233#include <stdlib.h>
    3334#include <string.h>
    3435#include <unistd.h>
    status_t  
    181182tun_up(net_device* _device)
    182183{
    183184    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);
    185189    if (device->fd < 0)
    186190        return errno;
    187191    ioctl(device->fd, TUNSETIFF);
  • src/bin/network/ifconfig/ifconfig.cpp

    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)  
    512512    if (status == B_OK) {
    513513        const char *type = "unknown";
    514514        switch (linkAddress.LinkLevelType()) {
     515            case IFT_TUN:
     516                type = "Tunnel";
     517                break;
    515518            case IFT_ETHER:
    516519                type = "Ethernet";
    517520                break;