From 696a9bc0a1c7f7d249be8ce27c57a7f8dfc60c87 Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Fri, 2 Jun 2023 18:01:23 +0900 Subject: [PATCH] Cedar: Don't hardcode prefix for virtual brige destination --- src/Cedar/BridgeUnix.c | 2 +- src/Cedar/Cedar.h | 3 ++- src/Cedar/SM.c | 3 ++- src/Cedar/VLanUnix.c | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Cedar/BridgeUnix.c b/src/Cedar/BridgeUnix.c index d5890cba..69fb20f3 100644 --- a/src/Cedar/BridgeUnix.c +++ b/src/Cedar/BridgeUnix.c @@ -321,7 +321,7 @@ TOKEN_LIST *GetEthListLinux(bool enum_normal, bool enum_rawip) { if (IsInListStr(o, name) == false) { - if (StartWith(name, "tap_") == false) + if (StartWith(name, UNIX_VLAN_BRDEST_IFACE_PREFIX"_") == false) { Add(o, CopyStr(name)); } diff --git a/src/Cedar/Cedar.h b/src/Cedar/Cedar.h index 7e3c88e0..5ce8afa0 100644 --- a/src/Cedar/Cedar.h +++ b/src/Cedar/Cedar.h @@ -675,7 +675,8 @@ // ////////////////////////////////////////////////////////////////////// -#define UNIX_VLAN_IFACE_PREFIX "vpn" // Prefix of UNIX virual LAN card interface +#define UNIX_VLAN_CLIENT_IFACE_PREFIX "vpn" // Prefix of UNIX virtual LAN card interface (used for client) +#define UNIX_VLAN_BRDEST_IFACE_PREFIX "tap" // Prefix of UNIX virtual LAN card interface (used for bridge destination) #ifndef UNIX_BSD #define TAP_FILENAME_1 "/dev/net/tun" diff --git a/src/Cedar/SM.c b/src/Cedar/SM.c index ce6d49b7..41c17700 100644 --- a/src/Cedar/SM.c +++ b/src/Cedar/SM.c @@ -7987,7 +7987,8 @@ void SmBridgeDlgOnOk(HWND hWnd, SM_SERVER *s) StrCpy(t.HubName, sizeof(t.HubName), hub); t.TapMode = tapmode; - if (InStrEx(t.DeviceName, UNIX_VLAN_IFACE_PREFIX, false) + if (InStrEx(t.DeviceName, UNIX_VLAN_CLIENT_IFACE_PREFIX, false) + || InStrEx(t.DeviceName, "UNIX_VLAN_BRDEST_IFACE_PREFIX, false) || InStrEx(t.DeviceName, "tun", false) || InStrEx(t.DeviceName, "tap", false)) { diff --git a/src/Cedar/VLanUnix.c b/src/Cedar/VLanUnix.c index 633c4fd9..41d29ed7 100644 --- a/src/Cedar/VLanUnix.c +++ b/src/Cedar/VLanUnix.c @@ -273,7 +273,7 @@ VLAN *NewTap(char *name, char *mac_address, bool create_up) return NULL; } - fd = UnixCreateTapDeviceEx(name, "tap", mac_address, create_up); + fd = UnixCreateTapDeviceEx(name, UNIX_VLAN_BRDEST_IFACE_PREFIX, mac_address, create_up); if (fd == -1) { return NULL; @@ -565,7 +565,7 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool cre } int UnixCreateTapDevice(char *name, UCHAR *mac_address, bool create_up) { - return UnixCreateTapDeviceEx(name, UNIX_VLAN_IFACE_PREFIX, mac_address, create_up); + return UnixCreateTapDeviceEx(name, UNIX_VLAN_CLIENT_IFACE_PREFIX, mac_address, create_up); } // Close the tap device @@ -701,7 +701,7 @@ bool UnixVLanCreateEx(char *name, char *prefix, UCHAR *mac_address, bool create_ } bool UnixVLanCreate(char *name, UCHAR *mac_address, bool create_up) { - return UnixVLanCreateEx(name, UNIX_VLAN_IFACE_PREFIX, mac_address, create_up); + return UnixVLanCreateEx(name, UNIX_VLAN_CLIENT_IFACE_PREFIX, mac_address, create_up); } // Set a VLAN up/down @@ -728,7 +728,7 @@ bool UnixVLanSetState(char* name, bool state_up) return false; } - GenerateTunName(name, UNIX_VLAN_IFACE_PREFIX, eth_name, sizeof(eth_name)); + GenerateTunName(name, UNIX_VLAN_CLIENT_IFACE_PREFIX, eth_name, sizeof(eth_name)); Zero(&ifr, sizeof(ifr)); StrCpy(ifr.ifr_name, sizeof(ifr.ifr_name), eth_name);