Commit Graph

469 Commits

Author SHA1 Message Date
roy 8b0aa988ec ifconfig: go back to using direct ioctls rather than data from getifaddrs
AF_LINK may not be the first address returned for the interface.
Technically, it *might* not even exist on the interface even though
other families do.
This is likely a driver bug if this really is the case though.

As such it's just easier to use direct ioctls rather than thump around
getifaddrs results. As it stands, the code makes a lot of getifaddrs
calls anyway, so an extra ioctl or two won't break the bank.
2020-10-14 13:37:14 +00:00
roy 2669b948a0 ifconfig: if SIOCGLIFADDR fails, continue to the next address 2020-10-11 21:32:37 +00:00
roy ec2482217d Minor correction to prior 2020-10-05 17:29:22 +00:00
roy a6f0f00cfa ifconfig: Warn once more if media supported but no types
This reverts media.c -r1.7
2020-10-05 16:17:05 +00:00
msaitoh b140fa3c95 Add [-]eee and [-]vlan-hwfilter. 2020-09-29 08:52:11 +00:00
roy 4d511cd47d ifconfig: Just look at if_data->ifi_link_state for carrier
It should be the sole source of truth.
if_data is also carried in ifa_data from getifaddrs(3) which saves
more ioctl calls.
2020-09-28 13:50:22 +00:00
roy c054c3f155 ifconfig: We already have struct if_data in ifa_data.
So let's not bother with an ioctl we don't need.
2020-09-26 23:43:26 +00:00
roy 4670a6a468 ifconfig: test cases want LINK_STATE_UNKNOWN to be treated as up. 2020-09-23 10:48:12 +00:00
roy 0fd9c80d4e ifconfig: teach carrier test about ifi_link_state from SIOCGIFDATA
Because not all interfaces support media.
2020-09-23 02:09:18 +00:00
roy bfeafc760c ifconfig: Report link state even if media is not supported
For AF_LINK addrs from getifaddrs(2), ifa_data is struct if_data.
This in turn holds ifi_link_state which we can use to report
link status if the interface does not support media where it's normally
reported.

Based on OpenBSD.
2020-09-22 14:14:17 +00:00
thorpej abcb66ec85 Update for proplib(3) API changes. 2020-06-07 05:54:00 +00:00
msaitoh 8012ca3f0e Remove extra semicolon. 2020-05-14 08:34:17 +00:00
plunky 7ea6ef2b6d trim extraneous return statement 2020-04-10 14:32:50 +00:00
ryo d5ec837d73 fix printing capabilities and enabled flags.
no need to skip a prefix "0x" of output of snprintb.
ifconfig expect the result of snprintb has "0x" prefix, but snprintb(3) specification has changed
so that if 0 is passed, it prints "0" instead of "0x0". (common/lib/libutil/snprintb.c r1.22)
2020-01-02 23:02:19 +00:00
kardel 479b835cf3 PR/54513 ifconfig exits on newly created carp interfaces
downgrade from err(EXIT_FAILURE, ... ) to warn() if ioctl(SIOCGLIFADDR) fails.
ifconfig now survives freshly created carp interfaces.
2019-10-01 10:52:53 +00:00
msaitoh 5ae436aa7e Whitespace fix. 2019-08-16 10:33:17 +00:00
msaitoh eea2ee1212 Implement VLAN hardware filter function(ETHERCAP_VLAN_HWFILTER).
First proposed by jmcneill in 2017 and modified by me.

How to use:

 - Set callback function:

	ether_set_vlan_cb(struct ethercom *, ether_vlancb_t)

 - Callback. This function is called when a vlan is attached/detached to the
   parent interface:

	int (*ether_vlancb_t)(struct ethercom *ec, uint16_t vlanid, bool set);

 - ifconfig(8)

	ifconfig ixg0 [-]vlan-hwfilter

 Note that ETHERCAP_VLAN_HWFILTER is set by default on ixg(4) because
the PF driver usually enable "all block" filter by default.
2019-07-17 03:26:24 +00:00
msaitoh cb1ccde89c KNF. No functional change. 2019-07-17 03:09:16 +00:00
msaitoh 83631b96b8 Add "ifconfig [-]vlan-hwtagging" to enable/disable VLAN hardware tagging
offload function. It's useful to see Ethernet frame's VLAN tag by
disabling with "ifconfig fooX -vlan-hwtagging" and "tcpdump -e -i fooX".
2019-07-08 03:04:15 +00:00
wiz 4785fe6db5 Formatting nit. 2019-07-04 13:55:31 +00:00
ozaki-r 86e9de9cad Add descr,description/-descr,-description commands to ifconfig(8) to handle a description.
From t-kusaba@IIJ
2019-07-04 02:45:45 +00:00
sevan edae29ee93 Add rcsid 2019-06-30 11:38:16 +00:00
msaitoh 1ad0ba196b Suggested by Christos:
- Dont' cast malloc()'s return value.
 - Use calloc() instead of malloc().
2019-04-22 10:44:55 +00:00
msaitoh 7b54e0066d Add SIOCSETHERCAP. It's used to change ec_capenable. 2018-12-21 08:58:08 +00:00
ozaki-r 75d57a2a1e Fix the format of ifconfig linkstr; it takes an argument 2018-11-15 04:37:20 +00:00
ozaki-r bd3e222d34 ifconfig: add linkstr/-linkstr to the help message 2018-11-15 04:36:46 +00:00
sevan 6733b800d4 Remove ISO & XNS references which are now long gone. 2018-07-31 20:54:18 +00:00
kamil 5f51a87ea5 Correct Undefined Behavior in ifconfig(8)
Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# ifconfig
alc0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ec_capabilities=3<VLAN_MTU,VLAN_HWTAGGING>
        ec_enabled=0
        address: xx:xx:xx:xx:xx:xx
/public/src.git/sbin/ifconfig/af_inet.c:102:34: runtime error: left shift of 16777215 by 8 places cannot be represented in type 'int'
        inet 192.168.0.38/24 broadcast 192.168.0.255 flags 0x0
        inet6 xxxx::xxxx:xxxx:xxxx:xxx%alc0/64 flags 0x0 scopeid 0x1
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33624
        inet 127.0.0.1/8 flags 0x0
        inet6 ::1/128 flags 0x20<NODAD>
        inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2

Change shifting left 1 to shifting 1U. This corrects the issue.

        if (cidr < 32) {                /* more than 1 bit in mask */
                /* check for non-contig netmask */
                if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0) // <- here
                        return -1;      /* noncontig, no pfxlen */
        }

Solution suggested by <uwe>

Sponsored by <The NetBSD Foundation>
2018-06-11 17:45:50 +00:00
christos 030580eaff user librumpres 2017-10-10 19:30:06 +00:00
christos fec7750749 We don't need agr or l2tp when we are small. 2017-05-02 20:12:27 +00:00
wiz d0da83b571 New sentence, new line.
Remove superfluous Oc and merge line to make it less likely to happen again.
Fix typo.
2017-02-16 13:51:08 +00:00
knakahara f8f075dfc2 add man for l2tp(4). 2017-02-16 08:32:21 +00:00
knakahara 03c4401a4e add l2tp(4) subcomands to ifconfig(8).
originally implemented by IIJ SEIL team.
2017-02-16 08:28:03 +00:00
rin 879e53004e Cosmetic changes. No functional changes. 2017-02-08 23:26:24 +00:00
rin d394916260 Factor out a common part in Makefile's of ifconfig and x_ifconfig. 2017-02-08 23:22:43 +00:00
rin 6323d1adb5 Rename sbin/ifconfig/Makefile.inc to Makefile.common; the former can
potentially conflict with bsd.subdir.mk.
2017-02-08 23:16:41 +00:00
rin 9766216654 Remove ifconfig hack on m68000. I've confirmed that the problem has already
gone with TME.
2017-02-08 23:13:59 +00:00
abhinav fc37131283 Fix typo: s/forwared/forwarded
Also remove full stop from the date.
2017-01-18 22:07:25 +00:00
kre 902f3d8946 Return to printing explicit "netmask 0x...." in the case that the
mask set is non-contiguous.   We don't prohibit setting such things
(even if they are basically useless) so they can be set by accident.
	ifconfig ifN 10.0.0.1 netmask 225.0.0.0
produced
	ifN .. inet 10.0.0.1/8
with the previous form (since 225 is 0xE1), now it produces
	ifN ... inet 10.0.0.1 netmask 0xe1000000

If the "netmask" form ever appears in ifconfig output, it (now)
means that the netmask is non-contig, which should make that case
obvious (whther intended, or set by accident)
2016-10-01 20:59:49 +00:00
roy 5174f725c2 Modernise the output for the address to address/prefix instead
of differring outputs for INET and INET6.
The hex string of the INET netmask was particulary hard to read.
2016-10-01 15:10:58 +00:00
roy b5123ad110 Remove the alias keyword from ifconfig output as it serves no purpose. 2016-09-30 16:52:17 +00:00
roy d55c25711c ifaddrs has more data than just the address.
Use it instead of making pointless ioctl calls.
2016-09-30 16:47:56 +00:00
christos e8e025ac01 fix bugs in ssid printing 2016-09-22 18:22:51 +00:00
roy c8fe052e74 Don't bail if SIOGIFMEDIA doesn't return any media lists because we
can still report link status.
2016-09-14 11:46:43 +00:00
christos 448df9d70c print address flag bits using snprintb 2016-09-13 00:20:51 +00:00
sevan 3ef31cfb4a Replace contractions & abbreviation. 2016-09-11 22:10:47 +00:00
christos 89e8cc1112 PR/50909: David Binderman: Optimize memset 2016-03-07 15:56:17 +00:00
christos 0598d5879b PR/50909: David Binderman: Optimize memset 2016-03-07 12:48:53 +00:00
riastradh ab04408fa8 Consistently use estrlcpy for ifr.ifr_name here, not strncpy. 2016-02-29 16:23:25 +00:00
roy 74efc0b2e3 -W seconds will wait for the detached flag to clear on addresses on
interfaces marked up to allow time for the carrier to appear on the
interface.

This does not extend the -w option duration.
2016-01-07 11:32:21 +00:00