mirror of
git://sourceware.org/git/glibc.git
synced 2024-12-21 04:31:04 +08:00
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Simplify
significantly. The device type is also part of the ifinfomsg data.
This commit is contained in:
parent
cbd52634e4
commit
1e2692c922
@ -1,5 +1,8 @@
|
|||||||
2007-11-14 Ulrich Drepper <drepper@redhat.com>
|
2007-11-14 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Simplify
|
||||||
|
significantly. The device type is also part of the ifinfomsg data.
|
||||||
|
|
||||||
* po/sv.po: Update from translation team.
|
* po/sv.po: Update from translation team.
|
||||||
* po/nl.po: Likewise.
|
* po/nl.po: Likewise.
|
||||||
|
|
||||||
|
@ -105,7 +105,6 @@ __check_native (uint32_t a1_index, int *a1_native,
|
|||||||
goto out_fail;
|
goto out_fail;
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int v4fd = -1;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
struct msghdr msg =
|
struct msghdr msg =
|
||||||
@ -134,46 +133,17 @@ __check_native (uint32_t a1_index, int *a1_native,
|
|||||||
|
|
||||||
if (nlmh->nlmsg_type == RTM_NEWLINK)
|
if (nlmh->nlmsg_type == RTM_NEWLINK)
|
||||||
{
|
{
|
||||||
/* A RTM_NEWLINK message can have IFLA_STATS data. We need to
|
|
||||||
know the size before creating the list to allocate enough
|
|
||||||
memory. */
|
|
||||||
struct ifinfomsg *ifim = (struct ifinfomsg *) NLMSG_DATA (nlmh);
|
struct ifinfomsg *ifim = (struct ifinfomsg *) NLMSG_DATA (nlmh);
|
||||||
struct rtattr *rta = IFLA_RTA (ifim);
|
int native = (ifim->ifi_type != ARPHRD_TUNNEL6
|
||||||
size_t rtasize = IFLA_PAYLOAD (nlmh);
|
&& ifim->ifi_type != ARPHRD_TUNNEL
|
||||||
int index = ifim->ifi_index;
|
&& ifim->ifi_type != ARPHRD_SIT);
|
||||||
|
|
||||||
if (a1_index == index || a2_index == index)
|
if (a1_index == ifim->ifi_index)
|
||||||
while (RTA_OK (rta, rtasize))
|
|
||||||
{
|
|
||||||
char *rta_data = RTA_DATA (rta);
|
|
||||||
size_t rta_payload = RTA_PAYLOAD (rta);
|
|
||||||
|
|
||||||
if (rta->rta_type == IFLA_IFNAME)
|
|
||||||
{
|
|
||||||
struct ifreq ifr;
|
|
||||||
*((char *) mempcpy (ifr.ifr_name, rta_data,
|
|
||||||
rta_payload))= '\0';
|
|
||||||
|
|
||||||
if (v4fd == -1)
|
|
||||||
{
|
|
||||||
v4fd = __socket (AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (v4fd == -1)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__ioctl (v4fd, SIOCGIFHWADDR, &ifr) >= 0)
|
|
||||||
{
|
|
||||||
int native
|
|
||||||
= (ifr.ifr_hwaddr.sa_family != ARPHRD_TUNNEL6
|
|
||||||
&& ifr.ifr_hwaddr.sa_family != ARPHRD_TUNNEL
|
|
||||||
&& ifr.ifr_hwaddr.sa_family != ARPHRD_SIT);
|
|
||||||
|
|
||||||
if (a1_index == index)
|
|
||||||
{
|
{
|
||||||
*a1_native = native;
|
*a1_native = native;
|
||||||
a1_index = 0xffffffffu;
|
a1_index = 0xffffffffu;
|
||||||
}
|
}
|
||||||
if (a2_index == index)
|
if (a2_index == ifim->ifi_index)
|
||||||
{
|
{
|
||||||
*a2_native = native;
|
*a2_native = native;
|
||||||
a2_index = 0xffffffffu;
|
a2_index = 0xffffffffu;
|
||||||
@ -183,12 +153,6 @@ __check_native (uint32_t a1_index, int *a1_native,
|
|||||||
&& a2_index == 0xffffffffu)
|
&& a2_index == 0xffffffffu)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
rta = RTA_NEXT (rta, rtasize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (nlmh->nlmsg_type == NLMSG_DONE)
|
else if (nlmh->nlmsg_type == NLMSG_DONE)
|
||||||
/* We found the end, leave the loop. */
|
/* We found the end, leave the loop. */
|
||||||
done = true;
|
done = true;
|
||||||
@ -198,8 +162,6 @@ __check_native (uint32_t a1_index, int *a1_native,
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
close_not_cancel_no_status (fd);
|
close_not_cancel_no_status (fd);
|
||||||
if (v4fd != -1)
|
|
||||||
close_not_cancel_no_status (v4fd);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user