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
This commit is contained in:
Konrad Witaszczyk 2024-06-28 10:28:55 +00:00
parent 5688843dc9
commit bb8fa2ef83

View File

@ -141,7 +141,7 @@ tun_open(char *dev_name, struct sockaddr *ouraddr, char *theiraddr)
* when tunN have no addresses, so - log and ignore it. * 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"); syslog(LOG_ERR,"SIOCDIFADDR - %m");
} }
@ -220,10 +220,8 @@ Finish(int signum)
/* /*
* Delete addresses for interface * Delete addresses for interface
*/ */
bzero(&ifra.ifra_addr, sizeof(ifra.ifra_addr)); bzero(&ifrq.ifr_addr, sizeof(ifrq.ifr_addr));
bzero(&ifra.ifra_broadaddr, sizeof(ifra.ifra_addr)); if (ioctl(s, SIOCDIFADDR, &ifrq) < 0) {
bzero(&ifra.ifra_mask, sizeof(ifra.ifra_addr));
if (ioctl(s, SIOCDIFADDR, &ifra) < 0) {
syslog(LOG_ERR,"can't delete interface's addresses - %m"); syslog(LOG_ERR,"can't delete interface's addresses - %m");
} }
closing_fds: closing_fds: