From bb8fa2ef83c91d4bd5538f4f445b4100ac141419 Mon Sep 17 00:00:00 2001 From: Konrad Witaszczyk Date: Fri, 28 Jun 2024 10:28:55 +0000 Subject: [PATCH] sbin/nos-tun: correct SIOCDIFADDR calls to use ifreq The SIOCDIFADDR ioctl takes an ifreq structure object, not an ifaliasreq structure object, as its argument. Reviewed by: brooks, jhb, oshogbo Approved by: oshogbo (mentor) Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D46017 --- sbin/nos-tun/nos-tun.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sbin/nos-tun/nos-tun.c b/sbin/nos-tun/nos-tun.c index f3af62db265b..ca0e33b2509a 100644 --- a/sbin/nos-tun/nos-tun.c +++ b/sbin/nos-tun/nos-tun.c @@ -141,7 +141,7 @@ tun_open(char *dev_name, struct sockaddr *ouraddr, char *theiraddr) * when tunN have no addresses, so - log and ignore it. * */ - if (ioctl(s, SIOCDIFADDR, &ifra) < 0) { + if (ioctl(s, SIOCDIFADDR, &ifrq) < 0) { syslog(LOG_ERR,"SIOCDIFADDR - %m"); } @@ -220,10 +220,8 @@ Finish(int signum) /* * Delete addresses for interface */ - bzero(&ifra.ifra_addr, sizeof(ifra.ifra_addr)); - bzero(&ifra.ifra_broadaddr, sizeof(ifra.ifra_addr)); - bzero(&ifra.ifra_mask, sizeof(ifra.ifra_addr)); - if (ioctl(s, SIOCDIFADDR, &ifra) < 0) { + bzero(&ifrq.ifr_addr, sizeof(ifrq.ifr_addr)); + if (ioctl(s, SIOCDIFADDR, &ifrq) < 0) { syslog(LOG_ERR,"can't delete interface's addresses - %m"); } closing_fds: