aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/generated.go
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@freebsd.org>2021-12-30 20:51:43 +0100
committerGitHub <noreply@github.com>2021-12-30 20:51:43 +0100
commit36bd2e4865254b8f17e4ab00a89d976d6f71d04b (patch)
tree4e07c8396e4ee68b22188107573c2831ac0fd7fa /pkg/csource/generated.go
parent2e49f10dbbcec83bf0aa7651c827503e1faec44c (diff)
executor: support larger maximum number of tun devices on *BSD (#2953)
Diffstat (limited to 'pkg/csource/generated.go')
-rw-r--r--pkg/csource/generated.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index 851bf935a..519b2fdd5 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -1672,14 +1672,20 @@ static int tunfd = -1;
#define MAX_TUN 4
#endif
#define TUN_IFACE "tap%d"
+#define MAX_TUN_IFACE_SIZE sizeof("tap2147483647")
#define TUN_DEVICE "/dev/tap%d"
+#define MAX_TUN_DEVICE_SIZE sizeof("/dev/tap2147483647")
#define LOCAL_MAC "aa:aa:aa:aa:aa:aa"
#define REMOTE_MAC "aa:aa:aa:aa:aa:bb"
#define LOCAL_IPV4 "172.20.%d.170"
+#define MAX_LOCAL_IPV4_SIZE sizeof("172.20.255.170")
#define REMOTE_IPV4 "172.20.%d.187"
-#define LOCAL_IPV6 "fe80::%02hxaa"
-#define REMOTE_IPV6 "fe80::%02hxbb"
+#define MAX_REMOTE_IPV4_SIZE sizeof("172.20.255.187")
+#define LOCAL_IPV6 "fe80::%02xaa"
+#define MAX_LOCAL_IPV6_SIZE sizeof("fe80::ffaa")
+#define REMOTE_IPV6 "fe80::%02xbb"
+#define MAX_REMOTE_IPV6_SIZE sizeof("fe80::ffbb")
static void vsnprintf_check(char* str, size_t size, const char* format, va_list args)
{
@@ -1729,10 +1735,10 @@ static void initialize_tun(int tun_id)
if (tun_id < 0 || tun_id >= MAX_TUN)
failmsg("tun_id out of range", "tun_id=%d", tun_id);
- char tun_device[sizeof(TUN_DEVICE)];
+ char tun_device[MAX_TUN_DEVICE_SIZE];
snprintf_check(tun_device, sizeof(tun_device), TUN_DEVICE, tun_id);
- char tun_iface[sizeof(TUN_IFACE)];
+ char tun_iface[MAX_TUN_IFACE_SIZE];
snprintf_check(tun_iface, sizeof(tun_iface), TUN_IFACE, tun_id);
#if GOOS_netbsd
@@ -1772,18 +1778,18 @@ static void initialize_tun(int tun_id)
#else
execute_command(1, "ifconfig %s ether %s", tun_iface, local_mac);
#endif
- char local_ipv4[sizeof(LOCAL_IPV4)];
+ char local_ipv4[MAX_LOCAL_IPV4_SIZE];
snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, tun_id);
execute_command(1, "ifconfig %s inet %s netmask 255.255.255.0", tun_iface, local_ipv4);
char remote_mac[sizeof(REMOTE_MAC)];
- char remote_ipv4[sizeof(REMOTE_IPV4)];
+ char remote_ipv4[MAX_REMOTE_IPV4_SIZE];
snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC);
snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, tun_id);
execute_command(0, "arp -s %s %s", remote_ipv4, remote_mac);
- char local_ipv6[sizeof(LOCAL_IPV6)];
+ char local_ipv6[MAX_LOCAL_IPV6_SIZE];
snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, tun_id);
execute_command(1, "ifconfig %s inet6 %s", tun_iface, local_ipv6);
- char remote_ipv6[sizeof(REMOTE_IPV6)];
+ char remote_ipv6[MAX_REMOTE_IPV6_SIZE];
snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, tun_id);
execute_command(0, "ndp -s %s%%%s %s", remote_ipv6, tun_iface, remote_mac);
}