Fwd: Re: Linpac and other AX.25 binaries failing to run on Debian Stretch
-------- Forwarded Message --------
Subject: Re: Linpac and other AX.25 binaries failing to run on Debian
Stretch
Date: Sun, 03 Sep 2017 11:06:26 +0200
From: Thomas Osterried <thomas@osterried.de>
To: David Ranch <dranch@trinnet.net>
CC: Colin Tuckley <colint@debian.org>, Ralf Baechle
<ralf@linux-mips.org>, Bernard, f6bvp <f6bvp@free.fr>, Basil Gunn -
N7NIX <basil@pacabunga.com>
> enxb827eb5f053b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
This length is 15 and needs a buffer size of 16.
Thanks to your strace, we see, that > ioctl(3, SIOCGIFHWADDR,
{ifr_name="enxb827eb5f05"}) = -1 ENODEV
..only 13 characters are copied.
Let's look at listen.c:
if (proto == ETH_P_ALL) {
strcpy(ifr.ifr_name, sa.sa_data);
if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
/usr/include/net/if.h:# define ifr_name ifr_ifrn.ifrn_name
and
/usr/include/net/if.h: char ifrn_name[IFNAMSIZ];
/usr/include/linux/if.h:#define IFNAMSIZ 16
=> so far so good. But what's up with sa.sa_data?
struct sockaddr sa;
int asize = sizeof(sa);
if ((size =
recvfrom(s, buffer, sizeof(buffer), 0, &sa,
&asize)) == -1) {
..
if (dev != NULL && strcmp(dev, sa.sa_data) != 0)
/usr/include/x86_64-linux-gnu/bits/socket.h: char sa_data[14];
=> sa_data can contain only 13 chars, plus \0. This is what we observed.
The question is:
- why linux's socket structures are incompatible to net/if ifr_name
- how the code has to be re-written in order to not use recfrom() /
sa_data for searching the interface?
- how many software in the universe has the same issue?
We have a patch in the queue from Wietse (-> Cc) from 2017-07.
He changes this part of the code and works with
struct sockaddr_ll sll;
...
recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&sll, ..
..
ifr.ifr_ifindex = sll.sll_ifindex
if (ioctl(sock, SIOCGIFNAME, &ifr) == -1 ) { /* Given the ifr_ifindex,
return the name of the interface in ifr_name. */
..
=> Imho, this should avoid the sockaddr sa_data incompatibility due to
the more modern design.
Wietse, do you like to test your version with an ethernet device on the
system set to a 15char long name?
vy 73,
- Thomas dl9sau
> --
> Could not initialize color support.
> --
:(
Reply to: