]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - fs/afs/netdevices.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* AFS network device helpers
4 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net>
7 #include <linux/string.h>
8 #include <linux/rtnetlink.h>
9 #include <linux/inetdevice.h>
10 #include <linux/netdevice.h>
11 #include <linux/if_arp.h>
12 #include <net/net_namespace.h>
16 * get a list of this system's interface IPv4 addresses, netmasks and MTUs
17 * - maxbufs must be at least 1
18 * - returns the number of interface records in the buffer
20 int afs_get_ipv4_interfaces(struct afs_net
*net
, struct afs_interface
*bufs
,
21 size_t maxbufs
, bool wantloopback
)
23 struct net_device
*dev
;
24 struct in_device
*idev
;
30 for_each_netdev(net
->net
, dev
) {
31 if (dev
->type
== ARPHRD_LOOPBACK
&& !wantloopback
)
33 idev
= __in_dev_get_rtnl(dev
);
36 for_primary_ifa(idev
) {
37 bufs
[n
].address
.s_addr
= ifa
->ifa_address
;
38 bufs
[n
].netmask
.s_addr
= ifa
->ifa_mask
;
39 bufs
[n
].mtu
= dev
->mtu
;