From 2634d16f4159b217417724b0cf2a834d5a816346 Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Tue, 16 Jan 2024 20:42:28 +0000 Subject: New upstream version 6.0.24.27 --- IPCode.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'IPCode.c') diff --git a/IPCode.c b/IPCode.c index efc4d91..7958b73 100644 --- a/IPCode.c +++ b/IPCode.c @@ -4539,6 +4539,50 @@ void OpenTAP() return; } + // Fix from github user isavitsky + + /* + * After some research I found that on most of my + * systems, including Raspberry Pi IV, a slight delay + * is needed before considering the TAP device + * up and running. Otherwise the interface structures + * do not initialise properly and later in the code + * around the line 4700 when we initialise our ARP + * structure: + * + * memcpy(Arp->HWADDR, xbuffer.ifr_hwaddr.sa_data, 6); + * + * the MAC address is getting filled in with random + * value which makes the communication via our TAP + * device using the configured IPADDR virtually + * impossible. + * + */ + + Debugprintf("Waiting for the TAP to become UP and RUNNING"); + + for (int i=10; i>0; i--) + { + Sleep(10); + + if ((err = ioctl(sockfd, SIOCGIFFLAGS, &ifr)) < 0) + { + perror("SIOCGIFFLAGS"); + return; + } + + if((ifr.ifr_flags & IFF_UP) && (ifr.ifr_flags & IFF_RUNNING)) + { + Debugprintf("TAP is UP and RUNNING"); + break; + } + else if (i == 1) + { + Debugprintf("TAP is still not UP and RUNNING"); + return; + } + } + printf("TAP brought up\n"); // Set MTU to 256 -- cgit v1.2.3