Giter Club home page Giter Club logo

ubridge's Introduction

uBridge

uBridge is a simple application to create user-land bridges between various technologies. Currently, bridging between UDP tunnels, Ethernet and TAP interfaces is supported. Packet capture is also supported.

Installation

Dependencies

  • pcap library (Winpcap on Windows).
  • pthread library.

For Ubuntu or other Debian based Linux you need to install this package:

  • libpcap-dev

Linux

In the source directory

make
sudo make install

FreeBSD

In the source directory

gmake
sudo gmake install

Be sure to modify gns3_server.conf to point to /usr/local/bin/ubridge

Windows

Install the dependencies:

  • Install Winpcap: https://www.winpcap.org/
  • Install Cygwin 32-bit (setup-x86.exe): https://cygwin.com/install.html
  • Run setup-x86.exe -X -q -O -s <ftp://www.fruitbat.org/pub/cygwin/circa/2016/08/30/104223> -P make -P gcc-core (install last package compatible with Windows)
  • Download and unzip Winpcap developer pack: http://www.winpcap.org/devel.htm
  • Copy the libraries WpdPack\Lib\libpacket.a and WpdPack\Lib\libwpcap.a to cygwin\lib\
  • Copy all headers from WpdPack\Include to cygwin\usr\include\

Open the Cygwin terminal:

git clone https://github.com/GNS3/ubridge.git
cd ubridge
make

You should get ubridge.exe if everything goes well.

Hypervisor mode

The hypervisor mode of uBridge allows you to dynamically add and remove bridges.

You can connect directly to the TCP control port with telnet.

Usage: ubridge -H [<ip_address>:]<tcp_port>

The command syntax is simple: [arguments...] For example: "bridge create test" creates a bridge named "test".

The modules that are currently defined are given below:

  • hypervisor : General hypervisor management
  • bridge : bridges management
  • iol_bridge : IOL (IOS on Linux) bridges management
  • docker : Docker veth management
  • brctl : Linux bridge management

Hypervisor module ("hypervisor")

  • hypervisor version: Display the version of dynamips.
hypervisor version
100-0.9.12
  • hypervisor module_list: Display the module list.
101 brctl
101 iol_bridge
101 docker
101 bridge
101 hypervisor
100-OK
  • hypervisor cmd_list <module>: Display commands recognized by the specified module.
hypervisor cmd_list bridge
101 list (min/max args: 0/0)
101 set_pcap_filter (min/max args: 1/2)
101 reset_packet_filters (min/max args: 1/1)
101 delete_packet_filter (min/max args: 2/2)
101 add_packet_filter (min/max args: 2/10)
101 stop_capture (min/max args: 1/1)
101 start_capture (min/max args: 2/3)
101 add_nio_linux_raw (min/max args: 2/2)
101 add_nio_ethernet (min/max args: 2/2)
101 add_nio_tap (min/max args: 2/2)
101 add_nio_unix (min/max args: 3/3)
101 delete_nio_udp (min/max args: 4/4)
101 remove_nio_udp (min/max args: 4/4)
101 add_nio_udp (min/max args: 4/4)
101 rename (min/max args: 2/2)
101 reset_stats (min/max args: 1/1)
101 get_stats (min/max args: 1/1)
101 show (min/max args: 1/1)
101 stop (min/max args: 1/1)
101 start (min/max args: 1/1)
101 delete (min/max args: 1/1)
101 create (min/max args: 1/1)
100-OK
  • hypervisor close: Close the current session.
hypervisor close
100-OK
Connection closed by foreign host.
  • hypervisor stop: Destroy all objects and stop hypervisor.
hypervisor stop
100-OK
Connection closed by foreign host.
  • hypervisor reset: Destroy all objects. (used to get an empty configuration)
hypervisor reset
100-OK

Bridge module (bridge)

  • bridge create <bridge_name>: Create a new bridge.
bridge create br0
100-bridge 'br0' created
  • bridge list: List all exiting Bridges.
bridge list
101 br0 (NIOs = 0)
100-OK
  • bridge delete <bridge_name>: Delete a bridge.
bridge delete br0
100-bridge 'br0' deleted
  • bridge start <bridge_name>: Start a bridge. A bridge must have 2 NIOs added in order to start.
bridge start br0
100-bridge 'br0' started
  • bridge stop <bridge_name>: Stop a bridge.
bridge stop br0
100-bridge 'br0' stopped
  • bridge rename <old_bridge_name> <new_bridge_name>: Rename a bridge.
bridge rename br0 br1
100-bridge 'br0' renamed to 'br1'
  • bridge add_nio_udp <bridge_name> <local_port> <remote_host> <remote_port>: Add an UDP NIO with the specified parameters to a bridge.
bridge add_nio_udp br0 20000 127.0.0.1 30000
100-NIO UDP added to bridge 'br0'
  • bridge delete_nio_udp <bridge_name> <local_port> <remote_host> <remote_port>: Remove an UDP NIO with the specified parameters to a bridge.
bridge delete_nio_udp br0 20000 127.0.0.1 30000
100-NIO UDP deleted from bridge 'br0'
  • bridge add_nio_unix <local> <remote>: Add an UNIX NIO with 'local' the UNIX domain socket to receive and 'remote' to send
bridge add_nio_unix br0 "/tmp/local" "/tmp/remote"
100-NIO UNIX added to bridge 'br0'
  • bridge add_nio_tap <bridge_name> <tap_device>: Add an TAP NIO to a bridge. TAP devices are supported only on Linux and FreeBSD and require root access.
bridge add_nio_tap br0 tap0
100-NIO TAP added to bridge 'br0'
  • bridge add_nio_ethernet <bridge_name> <eth_device>: Add a generic Ethernet NIO to a bridge, using PCAP (0.9.4 and greater). It requires root access.
bridge add_nio_ethernet br0 eth0
100-NIO Ethernet added to bridge 'br0'
  • bridge add_nio_linux_raw <bridge_name> <eth_device>: Add a Linux RAW Ethernet NIO. It requires root access and is supported only on Linux platforms.
bridge add_nio_linux_raw br0 eth0
100-NIO Linux raw added to bridge 'br0'
  • bridge add_nio_fusion_vmnet <bridge_name> <vmnet_device>: Add a Fusion VMnet NIO. It requires root access and is supported only on Mac OS X.
bridge add_nio_fusion_vmnet br0 vmnet1
100-NIO Fusion VMnet added to bridge 'br0'
  • bridge show <bridge_name>: Show the NIOs on a bridge.
bridge show bridge0
101 bridge 'br0' is running
101 Source NIO: 20000:127.0.0.1:30000
101 Destination NIO: eth0
  • bridge start_capture <bridge_name> <pcap_file> [pcap_linktype]: Start a PCAP packet capture on a bridge. PCAP link type default is Ethernet "EN10MB".
bridge start_capture br0 "/tmp/my_capture.pcap"
100-packet capture started on bridge 'br0'
  • bridge stop_capture <bridge_name>: Stop a PCAP packet capture on a bridge.
bridge stop_capture br0
100-packet capture stopped on bridge 'br0'
  • bridge set_pcap_filter <bridge_name> [filter]: Set a PCAP filter on a bridge. There must be a least one NIO Ethernet attached to the bridge. To reset any applied filter, same command without a filter.
bridge set_pcap_filter br0 "not ether src 00:50:56:c0:00:0a"
100-filter 'not ether src 00:50:56:c0:00:0a' applied on bridge 'br0'
bridge set_pcap_filter br0
100-filter reset on bridge 'br0'
  • bridge get_stats <bridge_name>: Show statistics about a bridge input/output.
bridge get_stats bridge0
101 Source NIO:      IN: 5 packets (90 bytes) OUT: 15 packets (410 bytes)
101 Destination NIO: IN: 15 packets (410 bytes) OUT: 5 packets (90 bytes)
  • bridge reset_stats <bridge_name>: Reset the statistics of a bridge.
bridge reset_stats bridge0
100-OK
  • bridge add_packet_filter <bridge_name> <filter_name> <filter_type> [<a4> [...<a10>]]: Add a packet filter to a bridge.

Filter types

frequency_drop

"frequency_drop" has 1 argument "<frequency>". It will drop everything with a -1 frequency, drop every Nth packet with a positive frequency, or drop nothing.

packet_loss

"packet_loss" has 1 argument "<percentage>" (0 to 100%). The percentage represents the chance for a packet to be lost.

delay

"delay" has 1 argument "<latency>" to delay packets in milliseconds and 1 optional argument "<jitter>" to add jitter in milliseconds (+/-) of the delay

corrupt

"corrupt" has 1 argument "<percentage>" (0 to 100%). The percentage represents the chance for a packet to be corrupted.

bpf

"bpf" has 1 argument "<filter_expression>", a string written with the Berkeley Packet Filter (BPF) syntax. This filter will drop any packet matching the expression. It also has 1 optional argument <pcap_linktype> which is the PCAP link type, the default is Ethernet "EN10MB".

bridge add_packet_filter br0 "my_filter1" "delay" 50 10
bridge add_packet_filter br0 "my_filter2" "frequency_drop" 5
bridge add_packet_filter br0 "my_filter3" "packet_loss" 20
bridge add_packet_filter br0 "my_filter4" "corrupt" 30
bridge add_packet_filter br0 "my_filter5" "bpf" "icmp[icmptype] == 8"
bridge add_packet_filter br0 "my_filter6" "bpf" "ether host 11:22:33:44:55:66"
bridge add_packet_filter br0 "my_filter7" "bpf" "tcp src port 53"
bridge show br0
101 bridge 'br0' is not running
101 Filter 'my_filter1' configured in position 1
101 Filter 'my_filter2' configured in position 2
101 Filter 'my_filter3' configured in position 3
101 Filter 'my_filter4' configured in position 4
101 Filter 'my_filter5' configured in position 5
101 Filter 'my_filter6' configured in position 6
101 Filter 'my_filter7' configured in position 7
101 Source NIO: 20000:127.0.0.1:30000
101 Destination NIO: 20001:127.0.0.1:30001
100-OK
  • bridge delete_packet_filter <bridge_name> <filter_name>: Delete a packet filter configured on a bridge.
bridge delete_packet_filter br0 "my_filter1"
100-Filter 'my_filter1' delete from bridge 'br0'

bridge reset_packet_filters <bridge_name>: Delete all packet filters configured on a bridge.

bridge reset_packet_filters br0
100-OK

Docker module ("docker")

  • docker create_veth <interface_name_1> <interface_name_2>: Create virtual Ethernet interface pair.
docker create_veth hostif guestif
100-veth pair created: hostif and guestif
  • docker move_to_ns <interface> <namespace_id> <dst_interface>: Move Ethernet interface to network namespace. And rename it after the move.
docker move_to_ns guestif 6367 eth0
100-guestif moved to namespace 6367
  • docker delete_veth <interface_name>: Delete virtual Ethernet interface.
docker delete_veth hostif
100-veth interface hostif has been deleted

Linux bridge ("brctl")

brctl addif virbr0 nat2
100-nat2 has been added to bridge virbr0}

IOL Bridge module ("iol_bridge")

  • iol_bridge create <name> <id>
iol_bridge create IOL-BRIDGE-513 513
100-IOL bridge 'IOL-BRIDGE-513' created
  • iol_bridge add_nio_udp <name> <iol_id> <bay> <unit> <lport> <rhost> <rport>
  • iol_bridge add_packet_filter <name> <bay> <unit> <filter_name> <filter_type>
  • iol_bridge reset_packet_filters <name> <bay> <unit>
  • iol_bridge start_capture <name> "<output_file>" <data_link_type>
  • iol_bridge delete <name>

Session example

This will bridge a tap0 interface to a UDP tunnel.

Start the hypervisor:

user@host# ./ubridge -H 2232
Hypervisor TCP control server started (port 2232).

Connect via telnet:

user@host# telnet localhost 2232
bridge create br0
100-bridge 'br0' created

bridge start br0
209-bridge 'br0' must have 2 NIOs to be started

bridge add_nio_tap br0 tap0
100-NIO TAP added to bridge 'br0'

bridge add_nio_udp br0 20000 127.0.0.1 30000
100-NIO UDP added to bridge 'br0'

bridge show br0
101 Source NIO: tap0
101 Destination NIO: 20000:127.0.0.1:30000
100-OK

bridge start br0
100-bridge 'br0' started

Config file mode

Usage: create a file named ubridge.ini in the same directory as uBridge and then start the executable.

Signal SIGHUP (not available on Windows) can be used to reload the config file.

Example of content:

; bridge Ethernet interface eth0 with an UDP tunnel
[bridge0]
source_ethernet = eth0
destination_udp = 10000:127.0.0.1:10001 ; syntax is local_port:remote_host:remote_port

; bridge TAP interface tap0 with an UDP tunnel
; and capture packets to /tmp/bridge1.pcap
[bridge1]
source_tap = tap0
destination_udp = 11000:127.0.0.1:11001
pcap_file = /tmp/bridge1.pcap
pcap_protocol = EN10MB ; PCAP data link type, default is EN10MB

; it is even possible to bridge two UDP tunnels and capture!
[bridge2]
source_udp = 40000:127.0.0.1:40001
destination_udp = 50000:127.0.0.1:50001
pcap_file = /tmp/bridge2.pcap

; or to bridge 2 interfaces
[bridge3]
source_tap = tap0
destination_ethernet = vmnet2

On Linux you can use a RAW socket to bridge an Ethernet interface (a bit faster than with the default PCAP method).

; bridge Ethernet interface eth0 with an UDP tunnel
; using the RAW socket method (Linux rocks!)
[bridge4]
source_linux_raw = eth0
destination_udp = 42000:127.0.0.1:42001

There is also the option to use a UNIX domain socket

; bridge UNIX domain socket with an UDP tunnel
[bridge5]
source_unix = /tmp/local_file:/tmp/remote_file
destination_udp = 42002:127.0.0.1:42003

On Mac OS X you can use the proprietary vmnet ktext module to bridge an VMware Fusion vmnet interface.

; bridge VMware FUsion interface vmnet1 with an UDP tunnel
[bridge6]
source_fusion_vmnet = vmnet1
destination_udp = 12000:127.0.0.1:12001

On Windows, interfaces must be specified with the NPF notation. You can display all available network devices using ubridge.exe -e on a command line.

; using a Windows NPF interface
[bridge7]
source_ethernet = "\Device\NPF_{BC46623A-D65B-4498-9073-96B9DC4C8CBA}"
destination_udp = 10000:127.0.0.1:10001
; this will filter out frames with source MAC address 00:50:56:c0:00:0a
pcap_filter = "not ether src 00:50:56:c0:00:0a"

Notes

  • A Bridge name (e.g. bridge4) can be anything as long it is unique in the same file or inside the hypervisor.
  • Capabitilies must be set on the executable (Linux only) or you must have administrator rights to bridge Ethernet or TAP interfaces.
  • It is only possible to bridge two interfaces or tunnels together. uBridge is not a hub or a switch!

ubridge's People

Contributors

ddompe avatar garrymar avatar gcetusic avatar grossmj avatar julien-duponchelle avatar mend-for-github-com[bot] avatar ocochard avatar omadjoudj avatar sebasdoes avatar vincentbernat avatar wilyarti avatar xatrekak avatar ziajka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ubridge's Issues

Implement some filters

Just some simple things.

  • Drop one packet every x packets.
  • Latence (wait x ms before sending a packet).

For more advanced features, I would prefer to use tc (traffic control) on Linux.

SYSTEM_INIPARSER option support

do I have to use the SYSTEM_INIPARSER option in the latest version?

ifeq ($(SYSTEM_INIPARSER),1)

because when I enable it I get these errors while compiling:
Selection_005

diff output btw initparser.c and your src/iniparser/iniparser.c:

diff -ur a/iniparser.c b/iniparser.c
--- a/iniparser.c	2019-05-17 12:06:17.204073297 +0300
+++ b/iniparser.c	2019-05-17 12:06:39.879468506 +0300
@@ -8,7 +8,6 @@
 /*--------------------------------------------------------------------------*/
 /*---------------------------- Includes ------------------------------------*/
 #include <ctype.h>
-#include <stdarg.h>
 #include "iniparser.h"
 
 /*---------------------------- Defines -------------------------------------*/
@@ -58,27 +57,18 @@
 
 /*-------------------------------------------------------------------------*/
 /**
-  @brief    Duplicate a string
-  @param    s String to duplicate
-  @return   Pointer to a newly allocated string, to be freed with free()
+  @brief    Copy string in a newly mallocced area
+  @param    str  String to copy.
+  @return   str  Copied version of the given string allocated with malloc
 
-  This is a replacement for strdup(). This implementation is provided
-  for systems that do not have it.
+  Original strdup is not portable, need to implement our own
  */
 /*--------------------------------------------------------------------------*/
-static char * xstrdup(const char * s)
+static char * _strdup(const char *s)
 {
-    char * t ;
-    size_t len ;
-    if (!s)
-        return NULL ;
-
-    len = strlen(s) + 1 ;
-    t = (char*) malloc(len) ;
-    if (t) {
-        memcpy(t, s, len) ;
-    }
-    return t ;
+    char * copy = (char*) malloc(strlen(s));
+    strcpy(copy, s);
+    return copy ;
 }
 
 /*-------------------------------------------------------------------------*/
@@ -88,7 +78,7 @@
   @return   unsigned New size of the string.
  */
 /*--------------------------------------------------------------------------*/
-static unsigned strstrip(char * s)
+unsigned strstrip(char * s)
 {
     char *last = NULL ;
     char *dest = s;
@@ -110,41 +100,6 @@
 
 /*-------------------------------------------------------------------------*/
 /**
-  @brief    Default error callback for iniparser: wraps `fprintf(stderr, ...)`.
- */
-/*--------------------------------------------------------------------------*/
-static int default_error_callback(const char *format, ...)
-{
-  int ret;
-  va_list argptr;
-  va_start(argptr, format);
-  ret = vfprintf(stderr, format, argptr);
-  va_end(argptr);
-  return ret;
-}
-
-static int (*iniparser_error_callback)(const char*, ...) = default_error_callback;
-
-/*-------------------------------------------------------------------------*/
-/**
-  @brief    Configure a function to receive the error messages.
-  @param    errback  Function to call.
-
-  By default, the error will be printed on stderr. If a null pointer is passed
-  as errback the error callback will be switched back to default.
- */
-/*--------------------------------------------------------------------------*/
-void iniparser_set_error_callback(int (*errback)(const char *, ...))
-{
-  if (errback) {
-    iniparser_error_callback = errback;
-  } else {
-    iniparser_error_callback = default_error_callback;
-  }
-}
-
-/*-------------------------------------------------------------------------*/
-/**
   @brief    Get number of sections in a dictionary
   @param    d   Dictionary to examine
   @return   int Number of sections found in dictionary
@@ -339,8 +294,7 @@
     if (! iniparser_find_entry(d, s)) return nkeys;
 
     seclen  = (int)strlen(s);
-    strlwc(s, keym, sizeof(keym));
-    keym[seclen] = ':';
+    sprintf(keym, "%s:", s);
 
     for (j=0 ; j<d->size ; j++) {
         if (d->key[j]==NULL)
@@ -378,8 +332,7 @@
     if (! iniparser_find_entry(d, s)) return NULL;
 
     seclen  = (int)strlen(s);
-    strlwc(s, keym, sizeof(keym));
-    keym[seclen] = ':';
+    sprintf(keym, "%s:", s);
 
     i = 0;
 
@@ -426,11 +379,11 @@
 
 /*-------------------------------------------------------------------------*/
 /**
-  @brief    Get the string associated to a key, convert to an long int
+  @brief    Get the string associated to a key, convert to an int
   @param    d Dictionary to search
   @param    key Key string to look for
   @param    notfound Value to return in case of error
-  @return   long integer
+  @return   integer
 
   This function queries a dictionary for a key. A key as read from an
   ini file is given as "section:key". If the key cannot be found,
@@ -451,46 +404,13 @@
   Credits: Thanks to A. Becker for suggesting strtol()
  */
 /*--------------------------------------------------------------------------*/
-long int iniparser_getlongint(const dictionary * d, const char * key, long int notfound)
+int iniparser_getint(const dictionary * d, const char * key, int notfound)
 {
     const char * str ;
 
     str = iniparser_getstring(d, key, INI_INVALID_KEY);
     if (str==INI_INVALID_KEY) return notfound ;
-    return strtol(str, NULL, 0);
-}
-
-
-/*-------------------------------------------------------------------------*/
-/**
-  @brief    Get the string associated to a key, convert to an int
-  @param    d Dictionary to search
-  @param    key Key string to look for
-  @param    notfound Value to return in case of error
-  @return   integer
-
-  This function queries a dictionary for a key. A key as read from an
-  ini file is given as "section:key". If the key cannot be found,
-  the notfound value is returned.
-
-  Supported values for integers include the usual C notation
-  so decimal, octal (starting with 0) and hexadecimal (starting with 0x)
-  are supported. Examples:
-
-  "42"      ->  42
-  "042"     ->  34 (octal -> decimal)
-  "0x42"    ->  66 (hexa  -> decimal)
-
-  Warning: the conversion may overflow in various ways. Conversion is
-  totally outsourced to strtol(), see the associated man page for overflow
-  handling.
-
-  Credits: Thanks to A. Becker for suggesting strtol()
- */
-/*--------------------------------------------------------------------------*/
-int iniparser_getint(const dictionary * d, const char * key, int notfound)
-{
-    return (int)iniparser_getlongint(d, key, notfound);
+    return (int)strtol(str, NULL, 0);
 }
 
 /*-------------------------------------------------------------------------*/
@@ -640,7 +560,7 @@
     char * line = NULL;
     size_t      len ;
 
-    line = xstrdup(input_line);
+    line = _strdup(input_line);
     len = strstrip(line);
 
     sta = LINE_UNPROCESSED ;
@@ -657,14 +577,9 @@
         strlwc(section, section, len);
         sta = LINE_SECTION ;
     } else if (sscanf (line, "%[^=] = \"%[^\"]\"", key, value) == 2
-           ||  sscanf (line, "%[^=] = '%[^\']'",   key, value) == 2) {
-        /* Usual key=value with quotes, with or without comments */
-        strstrip(key);
-        strlwc(key, key, len);
-        /* Don't strip spaces from values surrounded with quotes */
-        sta = LINE_VALUE ;
-    } else if (sscanf (line, "%[^=] = %[^;#]", key, value) == 2) {
-        /* Usual key=value without quotes, with or without comments */
+           ||  sscanf (line, "%[^=] = '%[^\']'",   key, value) == 2
+           ||  sscanf (line, "%[^=] = %[^;#]",     key, value) == 2) {
+        /* Usual key=value, with or without comments */
         strstrip(key);
         strlwc(key, key, len);
         strstrip(value);
@@ -711,7 +626,7 @@
   The returned dictionary must be freed using iniparser_freedict().
  */
 /*--------------------------------------------------------------------------*/
-dictionary * iniparser_load(const char * ininame)
+dictionary * iniparser_load(const char * ininame, load_options options)
 {
     FILE * in ;
 
@@ -725,12 +640,11 @@
     int  len ;
     int  lineno=0 ;
     int  errs=0;
-    int  mem_err=0;
 
     dictionary * dict ;
 
     if ((in=fopen(ininame, "r"))==NULL) {
-        iniparser_error_callback("iniparser: cannot open %s\n", ininame);
+        fprintf(stderr, "iniparser: cannot open %s\n", ininame);
         return NULL ;
     }
 
@@ -749,14 +663,14 @@
     while (fgets(line+last, ASCIILINESZ-last, in)!=NULL) {
         lineno++ ;
         len = (int)strlen(line)-1;
-        if (len<=0)
+        if (len==0)
             continue;
         /* Safety check against buffer overflows */
         if (line[len]!='\n' && !feof(in)) {
-            iniparser_error_callback(
-              "iniparser: input line too long in %s (%d)\n",
-              ininame,
-              lineno);
+            fprintf(stderr,
+                    "iniparser: input line too long in %s (%d)\n",
+                    ininame,
+                    lineno);
             dictionary_del(dict);
             fclose(in);
             return NULL ;
@@ -784,20 +698,27 @@
             break ;
 
             case LINE_SECTION:
-            mem_err = dictionary_set(dict, section, NULL);
+            errs = dictionary_set(dict, section, NULL);
             break ;
 
             case LINE_VALUE:
             sprintf(tmp, "%s:%s", section, key);
-            mem_err = dictionary_set(dict, tmp, val);
+            errs = dictionary_set(dict, tmp, val) ;
             break ;
 
             case LINE_ERROR:
-            iniparser_error_callback(
-              "iniparser: syntax error in %s (%d):\n-> %s\n",
-              ininame,
-              lineno,
-              line);
+
+            if(options & HIDE_ERRORED_LINE_CONTENT) {
+              fprintf(stderr, "iniparser: syntax error in %s (%d)\n",
+                      ininame,
+                      lineno);
+            }
+            else {
+              fprintf(stderr, "iniparser: syntax error in %s (%d):\n",
+                      ininame,
+                      lineno);
+              fprintf(stderr, "-> %s\n", line);
+            }
             errs++ ;
             break;
 
@@ -806,8 +727,8 @@
         }
         memset(line, 0, ASCIILINESZ);
         last=0;
-        if (mem_err<0) {
-            iniparser_error_callback("iniparser: memory allocation failure\n");
+        if (errs<0) {
+            fprintf(stderr, "iniparser: memory allocation failure\n");
             break ;
         }
     }

[Cosmetic] ubridge -v looks strange

As ubridge since 0.13 always shows the version on startup, ubridge -v gives a little strange output:

/Users/behlers/GNS3/source/ubridge# ./ubridge -v
uBridge version 0.9.13 running with libpcap version 1.5.3 - Apple version 54
ubridge version 0.9.13

Maybe ubridge -v could just exit, as the version is already shown. But I don't know, if GNS3 parses the output. But then the first line could result in some unwanted bugs.

IOU no connectivity after commit bbf32f7

I just built GNS3 gui/server v2.0.3 and the related utilities from source and while testing noticed there is no network traffic from IOU(IOL) nodes, other types of nodes are not affected (at least the ones I tested: dynamips, qemu), wireshark shows 0 packets coming from IOU.
Since master (bf19d3a) doesn't work and tag v0.9.11 does I did a git bisect and the culprit seems to be commit bbf32f7 (Implement filter support. Fixes #16.).
This is on Linux, Fedora 24, using a local gns server.

on debian sid (miss stdint.h)

⋊> ~/D/ubridge on master ◦ make 14:13:27
gcc -O3 -Wall -DLINUX_RAW -c -o ubridge.o ubridge.c
gcc -O3 -Wall -DLINUX_RAW -c -o nio.o nio.c
gcc -O3 -Wall -DLINUX_RAW -c -o nio_udp.o nio_udp.c
gcc -O3 -Wall -DLINUX_RAW -c -o nio_unix.o nio_unix.c
gcc -O3 -Wall -DLINUX_RAW -c -o nio_ethernet.o nio_ethernet.c
gcc -O3 -Wall -DLINUX_RAW -c -o nio_tap.o nio_tap.c
gcc -O3 -Wall -DLINUX_RAW -c -o iniparser/iniparser.o iniparser/iniparser.c
gcc -O3 -Wall -DLINUX_RAW -c -o iniparser/dictionary.o iniparser/dictionary.c
gcc -O3 -Wall -DLINUX_RAW -c -o parse.o parse.c
In file included from parse.c:33:0:
nio_linux_raw.h:29:5: error: unknown type name ‘uint16_t’
uint16_t vlan_tp_id;
^~~~~~~~
nio_linux_raw.h:30:5: error: unknown type name ‘uint16_t’
uint16_t vlan_tci;
^~~~~~~~
: recipe for target 'parse.o' failed
make: *** [parse.o] Error 1


add "#include <stdint.h>" to the nio_linux_raw.h
make success

Add more packet filters

2 ideas:

  • jitter filter (variation of delay).
  • corruption filter (to randomly corrupt packet data)

FortiGate VM 5.4.4 with 802.1q sub-interface not work

Hi~

Sub-interface with 802.1q tag in FortiGate VM 5.4.4 (KVM) on GNS3 1.5.3 doesn't work. I upgrade ubridge to version 0.9.11, but it still doesn't work. I try to create two 5.4.4 VM instances with same config in KVM by virt-manager, then connect them to same bridge. And It works well. My OS is Ubuntu 16.04. I am not sure if this issue is related to ubridge function?

Failure to detect long names of veth interface un creation

if (strlen(if1) > IFNAMSIZ || strlen(if2) > IFNAMSIZ) {

The check is wrong, should be:

if (strlen(if1) >= IFNAMSIZ || strlen(if2) >= IFNAMSIZ) {

This causes that when you allocate more than 100 ports to containers, the name exceeds the allowed length, but instead of receiving an message saying that the name is too long, you get a cryptic:

could not complete nettling transaction

Problems/ problema

Sorry my English
I have problems
Hello, I have the following problem.

I get this message

Bridge requires root access or capability to interact with network adapters

I'm using Palo Alto vmware

What Do I?

[0.9.17] Communication with tap interfaces is broken: recv: Connection refused

Debian bullseye
gns"-gui/server 2.2.6
gns3-ubridge 0.9.17

Communication with tap interface

The "A" node is a cloud with the configuration displayed in the window on the right.
Launching GNS3 leads to the GUI log:

GNS3 management console.
Running GNS3 version 2.2.6 on Linux (64-bit) with Python 3.7.7 Qt 5.12.5 and PyQt 5.14.1.
Copyright (c) 2006-2020 GNS3 Technologies.
Use Help -> GNS3 Doctor to detect common issues.

=> Running GNS3 as root is not recommended and could be dangerous
uBridge process has stopped, return code: 1
uBridge version 0.9.17 running with libpcap version 1.9.1 (with TPACKET_V3)
Hypervisor TCP control server started (IP 127.0.0.1 port 42091).
UDP tunnel connecting from local port 10079 to IPv4 address 127.0.0.1 on port 10078
UDP tunnel connecting from local port 10077 to IPv4 address 127.0.0.1 on port 10076
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-0 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-0 has started
UDP tunnel connecting from local port 10081 to IPv4 address 127.0.0.1 on port 10080
UDP tunnel connecting from local port 10034 to IPv4 address 127.0.0.1 on port 10035
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-1 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-1 has started
UDP tunnel connecting from local port 10083 to IPv4 address 127.0.0.1 on port 10082
UDP tunnel connecting from local port 10072 to IPv4 address 127.0.0.1 on port 10073
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-2 has started
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-2 has started
UDP tunnel connecting from local port 10085 to IPv4 address 127.0.0.1 on port 10084
UDP tunnel connecting from local port 10074 to IPv4 address 127.0.0.1 on port 10075
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-3 has started
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-3 has started
UDP tunnel connecting from local port 10087 to IPv4 address 127.0.0.1 on port 10086
UDP tunnel connecting from local port 10032 to IPv4 address 127.0.0.1 on port 10033
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-4 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-4 has started
UDP tunnel connecting from local port 10089 to IPv4 address 127.0.0.1 on port 10088
UDP tunnel connecting from local port 10052 to IPv4 address 127.0.0.1 on port 10053
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-5 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-5 has started
UDP tunnel connecting from local port 10091 to IPv4 address 127.0.0.1 on port 10090
UDP tunnel connecting from local port 10068 to IPv4 address 127.0.0.1 on port 10069
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-6 has started
UDP tunnel connecting from local port 10093 to IPv4 address 127.0.0.1 on port 10092
UDP tunnel connecting from local port 10004 to IPv4 address 127.0.0.1 on port 10005
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-7 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-6 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-7 has started
UDP tunnel connecting from local port 10095 to IPv4 address 127.0.0.1 on port 10094
UDP tunnel connecting from local port 10062 to IPv4 address 127.0.0.1 on port 10063
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-8 has started
UDP tunnel connecting from local port 10097 to IPv4 address 127.0.0.1 on port 10096
UDP tunnel connecting from local port 10046 to IPv4 address 127.0.0.1 on port 10047
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-9 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-8 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-9 has started
UDP tunnel connecting from local port 10099 to IPv4 address 127.0.0.1 on port 10098
UDP tunnel connecting from local port 10010 to IPv4 address 127.0.0.1 on port 10011
Source NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-10 has started
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-10 has started
recv: Connection refused
Destination NIO listener thread for QEMU-0426fff2-2efc-4f93-90fd-620735a54f3f-4 has stopped because of an error: Invalid argument 

uBridge process has stopped, return code: 1
uBridge version 0.9.17 running with libpcap version 1.9.1 (with TPACKET_V3)
Hypervisor TCP control server started (IP 127.0.0.1 port 45795).
UDP tunnel connecting from local port 10103 to IPv4 address 127.0.0.1 on port 10102
UDP tunnel connecting from local port 10035 to IPv4 address 127.0.0.1 on port 10034
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-0 has started
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-0 has started
UDP tunnel connecting from local port 10105 to IPv4 address 127.0.0.1 on port 10104
UDP tunnel connecting from local port 10066 to IPv4 address 127.0.0.1 on port 10067
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-1 has started
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-1 has started
UDP tunnel connecting from local port 10107 to IPv4 address 127.0.0.1 on port 10106
UDP tunnel connecting from local port 10006 to IPv4 address 127.0.0.1 on port 10007
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-2 has started
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-2 has started
UDP tunnel connecting from local port 10109 to IPv4 address 127.0.0.1 on port 10108
UDP tunnel connecting from local port 10060 to IPv4 address 127.0.0.1 on port 10061
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-3 has started
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-3 has started
UDP tunnel connecting from local port 10111 to IPv4 address 127.0.0.1 on port 10110
UDP tunnel connecting from local port 10020 to IPv4 address 127.0.0.1 on port 10021
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-4 has started
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-4 has started
UDP tunnel connecting from local port 10113 to IPv4 address 127.0.0.1 on port 10112
UDP tunnel connecting from local port 10070 to IPv4 address 127.0.0.1 on port 10071
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-5 has started
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-5 has started
UDP tunnel connecting from local port 10115 to IPv4 address 127.0.0.1 on port 10114
UDP tunnel connecting from local port 10044 to IPv4 address 127.0.0.1 on port 10045
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-6 has started
Source NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-6 has started
recv: Connection refused
Destination NIO listener thread for QEMU-5ea19190-702a-44cf-9a4c-5807c98197fd-0 has stopped because of an error: Invalid argument 

No such issue in the exact environment with:
gns3-gui/server 2.2.5
gns3-ubridge 0.9.16

Ubridge segfault

vagrant@gns3-iouvm:~$ telnet localhost 4242
bridge create b7052cc1-d49f-4e3f-844c-d53622cebafe-0
100-bridge 'b7052cc1-d49f-4e3f-844c-d53622cebafe-0' created
bridge add_nio_udp b7052cc1-d49f-4e3f-844c-d53622cebafe-0 30001 127.0.0.1 30000
UDP tunnel connecting from local port 30001 to IPv4 addresss 127.0.0.1 on port 30000
100-NIO UDP added to bridge 'b7052cc1-d49f-4e3f-844c-d53622cebafe-0'
bridge add_nio_linux_raw b7052cc1-d49f-4e3f-844c-d53622cebafe-0 "eth0"
100-NIO Linux raw added to bridge 'b7052cc1-d49f-4e3f-844c-d53622cebafe-0'
 bridge start b7052cc1-d49f-4e3f-844c-d53622cebafe-0
100-bridge 'b7052cc1-d49f-4e3f-844c-d53622cebafe-0' started
Destination NIO listener thread for b7052cc1-d49f-4e3f-844c-d53622cebafe-0 has started
Segmentation fault      (core dumped) ubridge -H 4242

Hypervisor mode

So bridges can be dynamically added/removed without reloading the config file (which is not supported on Windows because SIGHUP is not implemented on this platform).

ubridge 0.9.16 (GNS 2.2.5) doesn't work with tap interfaces on OS X

ubridge 0.9.16 (GNS 2.2.5) doesn't work with tap interfaces on OS X

I am having a problem with the same issue as Issues # 55.
Issues #55 did n’t give me a solution,
Please check again.
How can I connect?

image

  • Symptoms

Error while sending command 'bridge add_nio_tap 70f9e6d6-f9d5-4d20-8af9-24796f3b2054-9 "/ dev / tap0"': unable to create NIO TAP for bridge '70f9e6d6-f9d5-4d20-8af9-24796f3b2054-9': uBridge version 0.9 .16 running with libpcap version 1.8.1-Apple version 79.250.1
Hypervisor TCP control server started (IP localhost port 64869).
UDP tunnel connecting from local port 10000 to IPv4 addresses 127.0.0.1 on port 10001
create_nio_tap: unable to open TAP device / dev / tap0 (No such file or directory)

Cannot modify a cloud that is already connected.

—————————
My environment is as follows.
ubridge 0.9.16
GNS 2.2.5
OS X: 10.14.5 Mojave
—————————

The reproduction method is as follows.

==================
1.tuntap install
brew cask install tuntap

2.GNS3 Setting
GNS3 → Cloud → Configure → TAP interfaces

/ dev / tap0 add

3.Cabling

Cloud ———— cisco (Router)

==================

Recover from network adapter going down

send() returns an EINVAL Invalid argument error if a network adapter goes down (when bound an adapter it is using) which means that the thread in charge of copying data just stops.

https://github.com/GNS3/ubridge/blob/master/src/ubridge.c#L107L119

uBridge keeps running, nothing is reported to the GNS3 server and only a log entry is created. This issue also impacts GNS3/gns3-server#1634

I think there are 2 ways to recover from this:

  • Detect the EINVAL error and try to reconnect, for instance with an UDP NIO: https://github.com/GNS3/ubridge/blob/master/src/nio_udp.c#L152
  • Stop uBridge as soon as an error is detected and let the GNS3 server handle to situation, for instance by restarting uBridge and re sending all the commands to set it back up.

Cannot compile on FreeBSD 11

I cannot compile ubridge on FreeBSD 11.0-RELEASE:

gns3:/root/ubridge
11:42:08 # uname -a
FreeBSD gns3 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64
gns3:/root/ubridge
11:43:38 # gmake
gcc -O3 -Wall -c -o nio_udp.o nio_udp.c
nio_udp.c: In function 'udp_connect':
nio_udp.c:70:13: error: dereferencing pointer to incomplete type
sin->sin_family = PF_INET;
^
nio_udp.c:71:13: error: dereferencing pointer to incomplete type
sin->sin_port = htons(local_port);
^
nio_udp.c:72:54: error: dereferencing pointer to incomplete type
ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
^
nio_udp.c:81:14: error: dereferencing pointer to incomplete type
sin6->sin6_family = PF_INET6;
^
nio_udp.c:82:14: error: dereferencing pointer to incomplete type
sin6->sin6_port = htons(local_port);
^
nio_udp.c:83:55: error: dereferencing pointer to incomplete type
ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
^
gmake: *** [: nio_udp.o] Error 1

I've installed gmake, gcc, libpcap, and all other dependencies I could find.

Am I doing something wrong, is this not meant to be compiled on FreeBSD, or is this a bug?

Edit: I've attached a log with all installed packages and a monospace version of above logs.
log.txt

ubridge OS X binary of release 0.9.16 shows version 0.9.17

The OS X binary of release 0.9.16 shows version 0.9.17. As this binary is also included in the OS X package of GNS3 v2.1.19 (GNS3-2.1.19.dmg) the GNS3 package is also affected.

While this doesn't result in any bugs, it's quite unfortunate, that one can't rely on the version string displayed.

/Users/behlers# Downloads/ubridge-osx 
uBridge version 0.9.17 running with libpcap version 1.8.1 -- Apple version 79.20.1

The Linux binary shows the correct version string, I haven't checked the windows binary.

ubridge doesn't work with tap interfaces on OS X

ubridge 0.9.11 and 0.9.12, GNS3 version 2.0.4dev1 on Darwin (64-bit)

While TAP connections work in GNS3 v1.5, I wasn't able to use them on GNS3 V2.0, see also https://www.gns3.com/qa/how-to-connect-os-x-terminal-to-

Test project, router and cloud are running on the local OS X:
osxtap

Cloud configuration:
cloud_config

Other than in linux the TAP interfaces are not automatically detected in OS X. I have to use "/dev/tap0", otherwise the TAP device won't open, "tap0" as TAP device doesn't work.

After opening the TAP device I configured 10.1.1.1/24 on OS X and 10.1.1.100/24 on the router. But the router sees no (really 0) packets from OS X. Therefore no communication can happen.

In debug mode the ubridge.log looks like this:

/Users/behlers/GNS3/projects/osxtap/project-files/builtin/831e1592-8482-4b13-8605-2cfcca83c5c3# cat ubridge.log
recv: Input/output error
Hypervisor TCP control server started (IP 192.168.1.10 port 50638).
UDP tunnel connecting from local port 10000 to IPv4 addresss 192.168.1.10 on port 10001
Source NIO listener thread for 831e1592-8482-4b13-8605-2cfcca83c5c3-3 has started
Destination NIO listener thread for 831e1592-8482-4b13-8605-2cfcca83c5c3-3 has started
Destination NIO listener thread for 831e1592-8482-4b13-8605-2cfcca83c5c3-3 has stopped
Received 60 bytes on bridge '831e1592-8482-4b13-8605-2cfcca83c5c3-3' (source NIO)
0000: ff ff ff ff ff ff c2 01 03 bf 00 00 08 06 00 01 ................
0010: 08 00 06 04 00 02 c2 01 03 bf 00 00 0a 01 01 64 ...............d
0020: ff ff ff ff ff ff 0a 01 01 64 00 00 00 00 00 00 .........d......
0030: 00 00 00 00 00 00 00 00 00 00 00 00             ............

The hypervisor shows the following:

/Users/behlers/GNS3/projects/osxtap/project-files/builtin/831e1592-8482-4b13-8605-2cfcca83c5c3# telnet 192.168.1.10 50638
Trying 192.168.1.10...
Connected to imac.lan.
Escape character is '^]'.
bridge list
101 831e1592-8482-4b13-8605-2cfcca83c5c3-3 (NIOs = 2)
100-OK
bridge show 831e1592-8482-4b13-8605-2cfcca83c5c3-3
101 bridge '831e1592-8482-4b13-8605-2cfcca83c5c3-3' is running
101 Source NIO: 10000:192.168.1.10:10001
101 Destination NIO: /dev/tap0
100-OK

Windows - get_stats shows empty (0 bytes) packets out to local interface

I have a version of the infamous GNS3 Windows 10 host Cloud not working. I have a couple details about the issue I haven't seen in my searching though.

It does work for my regular LAN NIC. The router device I'm using (Mikrotik CHR) can DHCP from the LAN in my house and talk to the internet just like any other computer here in another room.

That's the only interface it works with. I've tried TAPs(media set to always connected and app controlled), Loopbacks(created by GNS#'s loopback-manager.cmd), and a couple additional VMNetX's (created via GNS3's vmnet-manager.cmd).

I finally gave in and worked around it as recommended in
#43

  • I added a 3rd "Custom" Network Adapter set to VMNet4 int the GNS3 VM via VMWarePlayer.
  • This shows up as eth2 in GNS3 VM if you reboot the VM
  • Add Cloud device that runs on GNS3 VM
  • Make your connection from Cloud eth2 to your router device.

Anyway, while troubleshooting, here's the interesting thing I found:

With the ubridge tunnel going from GNS3 VM (running the router device) to the local GNS3 server (running the Cloud) the get_stats hypervisor command shows packets properly flowing through the UDP tunnel but the "out bytes" count on one side is always 0.

101 4e2a2ee8-10d8-40a5-963b-3f1ef57d9ac1-1 (NIOs = 2)
100-OK
bridge show 4e2a2ee8-10d8-40a5-963b-3f1ef57d9ac1-1
101 bridge '4e2a2ee8-10d8-40a5-963b-3f1ef57d9ac1-1' is running
101 Source NIO: 10033:192.168.80.128:10053
101 Destination NIO: \Device\NPF_{3C5AB807-29F3-451A-B155-4F4CDCC2C11B}
100-OK
bridge get_stats 4e2a2ee8-10d8-40a5-963b-3f1ef57d9ac1-1
101 Source NIO: IN: 167 packets (8550 bytes) OUT: 197 packets (29284 bytes)
101 Destination NIO: IN: 197 packets (29284 bytes) OUT: 167 packets (0 bytes)
100-OK

Not many packets are shown in the captured stats above but I had previously ran pings from each end and let it run over night. Thousands of packets and bytes matched all around except for OUT on the host going to the Loopback device.

Also, sniffing with wireshark supports the idea the bytes output to the host are empty. I can see both directions of traffic in wireshark capturing via GNS3 (right click on link and start capture). But, if I run wireshark and sniff on the actual Loopback adapter on the Host, I see only outgoing packets. No frames ever make it to host.

The stats and sniffing was the same for TAP, loopbacks and VMnet devices I tried. Firewall was completely disabled for domain,public and private. I also added a ubridge.exe exception just to be sure.

Maybe the 'empty" packets output I've added above will help someone figure something out, or point me where to dig deeper.

VMWare vms randomly losing connectivity

Hello,

First things first:

  • OS: Windows 10 Pro
  • VMWare Workstation 15
  • GNS3 Version: 2.2.7 + GNS VM 2.2.7 running on said hypervisor, freshly reinstalled.
  • Windows Server VMWare VM [172.10.10.10] also on VMWare Workstation.
  • FortiGate appliance [172.20.10.1] running on the GNS3 VM.
  • Both devices are connected to a GNS3 ethernet switch and it doesn't matter that if it runs on my local server or the GNS3 VM.

Let's say that I connect the cable from the Windows Server to the ethernet switch and it works for a while. Then, out of nowhere (I don't touch anything) it losses the connection.

I did some digging and noticed that GNS3 changed the network adapter to vmnet10, as espected and If I sniff traffic while it's working I see bidirectional traffic on vmnet10 and the ubridge encapsulated packets.

When it stops working, I see only the Windows Server ARP requests in vmnet10, while in the ubridge tunnel I see both arp request and replies... as if it somehow stopped injecting packets in vmnet10. The bridge is still listed, though:

bridge list
100-OK
bridge list
101 ethernet0.vnet (NIOs = 2)
100-OK
bridge show ethernet0.vnet
101 bridge 'ethernet0.vnet' is running
101 Source NIO: \Device\NPF_{320C4731-9E0D-4777-AF47-D696FB43FB55}
101 Destination NIO: 10003:192.168.11.1:10004
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 100 packets (9502 bytes) OUT: 100 packets (0 bytes)
101 Destination NIO: IN: 100 packets (20250 bytes) OUT: 100 packets (9502 bytes)
100-OK
bridge list
101 ethernet0.vnet (NIOs = 2)
100-OK
bridge show ethernet0.vnet
101 bridge 'ethernet0.vnet' is running
101 Source NIO: \Device\NPF_{320C4731-9E0D-4777-AF47-D696FB43FB55}
101 Destination NIO: 10003:192.168.11.1:10004
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 152 packets (13334 bytes) OUT: 138 packets (0 bytes)
101 Destination NIO: IN: 139 packets (24530 bytes) OUT: 152 packets (13334 bytes)
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 161 packets (13712 bytes) OUT: 138 packets (0 bytes)
101 Destination NIO: IN: 139 packets (24530 bytes) OUT: 161 packets (13712 bytes)
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 168 packets (14006 bytes) OUT: 138 packets (0 bytes)
101 Destination NIO: IN: 139 packets (24530 bytes) OUT: 168 packets (14006 bytes)
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 173 packets (14216 bytes) OUT: 138 packets (0 bytes)
101 Destination NIO: IN: 139 packets (24530 bytes) OUT: 173 packets (14216 bytes)
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 175 packets (14300 bytes) OUT: 138 packets (0 bytes)
101 Destination NIO: IN: 139 packets (24530 bytes) OUT: 175 packets (14300 bytes)
100-OK
bridge get_stats ethernet0.vnet
101 Source NIO: IN: 179 packets (14468 bytes) OUT: 138 packets (0 bytes)
101 Destination NIO: IN: 139 packets (24530 bytes) OUT: 179 packets (14468 bytes)
100-OK

I repeated the stats command when I lost connectivity.

FWIW, I've attached the packet captures. Feel free to ask if you need anything else, I can reproduce the problem in minutes.

Max
gns3 gns3 vm
gns3 server main server
gns3 vmware advanced local settings
gns3 vmware vmware vms
captures.zip

Windows 10 - Cloud Node Issue

I have issues using the cloud node to connect virtual devices to the host.

I can narrow down the problem using a simple test with the cloud node (on the host) and a VPCS:

  • VPCS on host, connected to VMWare or VirtualBox hostonly adapter: Connection successful
  • VPS on GNS3 VM, connected to VMWare or VirtualBox hostonly adapter: Connection unsuccessful

Therefore, I think the problem is somewhere in the connection through the GNS3 VM.

I tried several versions of pcap and npcap with both installed, only winpcap or only npcap with compatibility mode. I also tried using different versions of ubridge (0.9.10,0.9.11,0.9.13). Using different GNS3 versions (2.0.0,2.0.3,2.1.0b1) also didn't result in any success.

More details on the connectivity tests I did: GNS3 forum

Thanks,
Dominik

ubridge 0.9.13 (GNS 2.1.11) doesn't work with tap interfaces on OS X

Hi there,

It appears ubridge 0.9.13 is unable to detect and run tap interfaces for GNS 2.1.11 MacOS 10.14.2. I started GNS3 as root and when I set up a test project with a Cisco IOS router and cloud/tap interface on the local OS X, I get the following error when I attempt to connect the router to the cloud's tap interface:

Error while sending command 'bridge add_nio_tap 5c076a45-9514-4f40-996a-3cf29b80f03b-5 "/dev/tap4"': unable to create NIO TAP for bridge '5c076a45-9514-4f40-996a-3cf29b80f03b-5': uBridge version 0.9.13 running with libpcap version 1.8.1 -- Apple version 79.200.4
Hypervisor TCP control server started (IP 127.0.0.1 port 57658).
UDP tunnel connecting from local port 10001 to IPv4 addresss 127.0.0.1 on port 10000
create_nio_tap: unable to open TAP device /dev/tap4 (No such file or directory)

screenshot 2019-01-12 at 00 27 17

Tap interface driver installed is tun tap and I've been able to manually bring up the tap interfaces and assign IPs for respective tap interfaces and it all works fine. So the issue appears to be with ubridge. Is this a known issue? Please is there a fix or workaround?

uBridge requires root access or the capability to interact with network adapters

Hi,
I'm using Debian buster
when I add a virtual machine (which I pull from docker) I get this error uBridge requires root access or the capability to interact with network adapters
I've installed ubridge and it has permission.
for example, I tried ubridge -H 5000 and it works.
if I add a virtual machine from virtual box everything is okay, so my problem is with Docker
what should I do?

Compiler warnings in iniparser.c

Three warnings in src/iniparser/iniparser.c are shown when building ubridge, here a full log: https://ci.appveyor.com/project/gns3-build/ubridge/builds/32494335

cc -O3 -Wall -IWpdPack\Include   -c -o src/iniparser/iniparser.o src/iniparser/iniparser.c
In file included from src/iniparser/iniparser.c:10:
src/iniparser/iniparser.c: In function ‘iniparser_load’:
src/iniparser/iniparser.c:766:52: warning: array subscript has type ‘char’ [-Wchar-subscripts]
  766 |                 ((line[len]=='\n') || (isspace(line[len])))) {
      |                                                ~~~~^~~~~
src/iniparser/iniparser.c:791:32: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
  791 |             sprintf(tmp, "%s:%s", section, key);
      |                                ^
src/iniparser/iniparser.c:791:13: note: ‘sprintf’ output between 2 and 2050 bytes into a destination of size 2049
  791 |             sprintf(tmp, "%s:%s", section, key);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

optimize create_filter ?

Hi

To seek the bug "C99 or C11 mode" , i see the function "create_filter" of "packet_filter.c"

Will this function be more efficience if the "for" instruction exports the calcul of "lookup_table + sizeof(lookup_table) / sizeof(lookup_table[0])" in a variable before the "for" ?

Can't build ubridge on OSX

In file included from packet_filter.c:23:
./packet_filter.h:39:4: error: unknown type name 'u_int'
  u_int type;
  ^
1 error generated.
make: *** [packet_filter.o] Error 1

Ploblmes in gns3

Sorry my English
I have problems
Hello, I have the following problem.

MacOS Mojave
I receive this message when connecting the Switch L2"default" to the cloud

Server error from http://127.0.0.1:8000: SW1: unable to create generic ethernet NIO

SOLVED!!
sudo chown root:admin /Applications/GNS3.app/Contents/MacOS/ubridge
sudo chmod 4750 /Applications/GNS3.app/Contents/MacOS/ubridge

sudo chown root /Applications/GNS3.app/Contents/Resources/dynamips
sudo chmod +s /Applications/GNS3.app/Contents/Resources/dynamips

docker move_to_ns issue (GNS3 2.2.19 - Gentoo Linux)

Hi guys,

I am experiencing some problems while trying to bring up a docker container within GNS3. After running gns3server with '-d' I found the output:

2021-03-24 19:01:48 ERROR route.py:242 Uncaught exception detected: <class 'KeyError'>
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/gns3server/compute/base_node.py", line 631, in _ubridge_send
await self._ubridge_hypervisor.send(command)
File "/usr/lib/python3.8/site-packages/gns3server/utils/asyncio/init.py", line 163, in wrapper
return await f(oself, *args, **kwargs)
File "/usr/lib/python3.8/site-packages/gns3server/ubridge/ubridge_hypervisor.py", line 259, in send
raise UbridgeError(data[-1][4:])
gns3server.ubridge.ubridge_error.UbridgeError: could not complete netlink transaction

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/gns3server/compute/docker/docker_vm.py", line 914, in _add_ubridge_connection
await self._ubridge_send('docker move_to_ns {ifc} {ns} eth{adapter}'.format(ifc=adapter.host_ifc,
File "/usr/lib/python3.8/site-packages/gns3server/compute/base_node.py", line 633, in _ubridge_send
raise UbridgeError("Error while sending command '{}': {}: {}".format(command, e, self._ubridge_hypervisor.read_stdout()))
gns3server.ubridge.ubridge_error.UbridgeError: Error while sending command 'docker move_to_ns tap-gns3-e0 27347 eth0': could not complete netlink transaction: uBridge version 0.9.18 running with libpcap version 1.10.0 (with TPACKET_V3)
Hypervisor TCP control server started (IP 0.0.0.0 port 36283).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/gns3server/compute/docker/docker_vm.py", line 478, in start
await self._add_ubridge_connection(nio, adapter_number)
File "/usr/lib/python3.8/site-packages/gns3server/compute/docker/docker_vm.py", line 918, in _add_ubridge_connection
raise UbridgeNamespaceError(e)
gns3server.ubridge.ubridge_error.UbridgeNamespaceError: Error while sending command 'docker move_to_ns tap-gns3-e0 27347 eth0': could not complete netlink transaction: uBridge version 0.9.18 running with libpcap version 1.10.0 (with TPACKET_V3)
Hypervisor TCP control server started (IP 0.0.0.0 port 36283).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/gns3server/web/route.py", line 198, in control_schema
await func(request, response)
File "/usr/lib/python3.8/site-packages/gns3server/handlers/api/compute/docker_handler.py", line 89, in start
await container.start()
File "/usr/lib/python3.8/site-packages/gns3server/compute/docker/docker_vm.py", line 484, in start
logdata = await self._get_log()
File "/usr/lib/python3.8/site-packages/gns3server/compute/docker/docker_vm.py", line 1141, in _get_log
result = await self.manager.query("GET", "containers/{}/logs".format(self._cid), params={"stderr": 1, "stdout": 1})
File "/usr/lib/python3.8/site-packages/gns3server/compute/docker/init.py", line 114, in query
if response.headers['CONTENT-TYPE'] == 'application/json':
KeyError: 'CONTENT-TYPE'

I've executed ubridge hypervisor mode and accessed it by telnet. The docker move_to_ns command does not work in my environment. Please, could someone help to fix this?

Thanks in advance
Regards

Check for UDP tunnel can send/receive

It would be really nice if there was a way to get udp tunnel to do a ping/pong test to verify data sent was received. I had a compute node die and migrated everything over to another box. I aliased the ip (ip address add bla dev bla) with the old server to the new server (ens3.66 had .100 and .101 (100 old 101 new)) and was able to load the gui without issue but couldn't' figure out why I couldn't communicate outside of gns3. Even devices on the same switch couldn't communicate. This is with the gui connecting to .100 address.

After a lot of trouble shooting I removed the gns3 home dir and found I could attach devices to the network. In the end and I still don't understand why,the issue was the udp tunnels ubridge creates were not able to communicate. Even after blowing away all iptables rules. After disabling the host line that bound gns3 to a 2nd IP on the interface I was then able to attach VMs to the network and get data.

I've never questioned my GNS3 know how so much in one day. :D

Error when make : only allowed in C99 or C11 mode

Hi

On debian jessie, make command does this error message

gcc -O3 -Wall -DLINUX_RAW   -c -o src/parse.o src/parse.c
gcc -O3 -Wall -DLINUX_RAW   -c -o src/packet_filter.o src/packet_filter.c
src/packet_filter.c: In function 'create_filter':
src/packet_filter.c:224:4: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    for (filter_table_t *plookup = lookup_table;
    ^
src/packet_filter.c:224:4: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
<builtin>: recipe for target 'src/packet_filter.o' failed
make: *** [src/packet_filter.o] Error 1
gcc -O3 -Wall -DLINUX_RAW   -c -o src/packet_filter.o src/packet_filter.c
src/packet_filter.c: In function 'create_filter':
src/packet_filter.c:224:4: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    for (filter_table_t *plookup = lookup_table;
    ^
src/packet_filter.c:224:4: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
<builtin>: recipe for target 'src/packet_filter.o' failed
make: *** [src/packet_filter.o] Error 1

To solve, you can modify the Makefile to add to the variable "CFLAGS" the value "-std=gnu99"

CFLAGS  =   -O3 -Wall -std=gnu99

Wrong documentation - 'bridge stats' should be 'bridge get_stats'

The readme file says that 'bridge stats' should show the stats. That does not work.
The documentation is is also not consistent with the actual output of 'hypervisor cmd_list hypervisor', which says that the command is 'bridge get_stats'.

bridge stats DYNAMIPS-20002-20003
202-Unknown command 'stats'

bridge get_stats DYNAMIPS-20002-20003
101 Source NIO: IN: 21489 packets (1339583 bytes) OUT: 33437 packets (2643643 bytes)
101 Destination NIO: IN: 33437 packets (2643643 bytes) OUT: 21489 packets (1339583 bytes)
100-OK

Allow to use a TAP interface multiple time

You get the following message if you attach to a TAP more than once:

unable to create NIO TAP for bridge 'cfc22796-ad24-4101-ab1e-eedffdf623c5-0': create_nio_tap: unable to open TAP device tap0 (Device or resource busy)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.