Skip to content

Commit

Permalink
Merge pull request #874 from appneta/Bug_#828_linux_tap_interfaces_fa…
Browse files Browse the repository at this point in the history
…il_intermittently

Bug #844 tap: ignore TUNSETIFF EBUSY errors
  • Loading branch information
fklassen authored Jun 8, 2024
2 parents a4af458 + d6f7c5a commit 4db9f5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
6 changes: 5 additions & 1 deletion docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
- add check for IPv6 extension header length (#827 #842)
- GitHub template for pull requests (#839)
- handle IPv6 fragment extension header (#832 #837)
- Linux tap interfaces fail intermittently (#828)
- Infinite loop in tcprewrite at get.c (#827 #842)
- SLL incorrect size and protocal when converted to Ethernet (#826)
- CVE-2023-43279 add check for empty CIDR (#824 #843)
- AF_XDF socket extension (#822 #823)
- configure.ac: unify search dirs for pcap and add lib32 (#819)
- tcpreplay-edit recomputes IPv4 checksums unnecessarily (#815 #846)
- CVE-2023-4256 double free in tcprewrite DLT_JUNIPER_ETHER (#813 #851)
- dlt_jnpr_ether_cleanup: check config before cleanup (#812 #851)
- SEGV on invalid Juniper Ethernet header length (#811)
Expand All @@ -25,7 +28,8 @@
06/04/2023 Version 4.4.4
- overflow check fix for parse_mpls (#795)
- tcpreplay-edit: prevent L2 flooding of ipv6 unicast packets (#793)
- CVE-2023-27784 CVE-2023-27785 CVE-2023-27786 CVE-2023-27787 CVE-2023-27788 CVE-2023-27789 bugs caused by strtok_r (#782 #784 #785 #786 #787 #788)
- CVE-2023-27784 CVE-2023-27785 CVE-2023-27786 CVE-2023-27787 CVE-2023-27788 CVE-2023-27789
bugs caused by strtok_r (#782 #784 #785 #786 #787 #788)
- CVE-2023-27783 reachable assert in tcpedit_dlt_cleanup (#780)
- add CI and C/C++ Linter and CodeQL (#773)
- reachable assert in fast_edit_packet (#772)
Expand Down
20 changes: 7 additions & 13 deletions src/common/sendpacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,6 @@ sendpacket_open(const char *device,
sendpacket_type_t sendpacket_type _U_,
void *arg _U_)
{
#ifdef HAVE_TUNTAP
char sys_dev_dir[128];
bool device_exists;
#endif
sendpacket_t *sp;
struct stat sdata;

Expand All @@ -536,11 +532,6 @@ sendpacket_open(const char *device,

errbuf[0] = '\0';

#ifdef HAVE_TUNTAP
snprintf(sys_dev_dir, sizeof(sys_dev_dir), "/sys/class/net/%s/", device);
device_exists = access(sys_dev_dir, R_OK) == 0;
#endif

/* khial is universal */
if (stat(device, &sdata) == 0) {
if (((sdata.st_mode & S_IFMT) == S_IFCHR)) {
Expand All @@ -563,7 +554,7 @@ sendpacket_open(const char *device,
}
}
#ifdef HAVE_TUNTAP
} else if (strncmp(device, "tap", 3) == 0 && !device_exists) {
} else if (strncmp(device, "tap", 3) == 0) {
sp = sendpacket_open_tuntap(device, errbuf);
#endif
} else {
Expand Down Expand Up @@ -895,9 +886,12 @@ sendpacket_open_tuntap(const char *device, char *errbuf)
strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name) - 1);

if (ioctl(tapfd, TUNSETIFF, (void *)&ifr) < 0) {
snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to create tuntap interface: %s", device);
close(tapfd);
return NULL;
// ignore EBUSY - it just means that the tunnel has already been opened
if (errno != EBUSY) {
snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to create tuntap interface: %s errno=%d", device, errno);
close(tapfd);
return NULL;
}
}
#elif defined(HAVE_FREEBSD)
if (*device == '/') {
Expand Down

0 comments on commit 4db9f5b

Please sign in to comment.