aboutsummaryrefslogtreecommitdiff
path: root/net
Commit message (Collapse)AuthorAgeFilesLines
* net/l2tp.sh: Rewrite to address issues of POSIX conformance (and more besides)Kerin Millar2023-01-151-143/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure that awk(1) is used portably throughout. Eliminate the use of ${parameter^^} expansion syntax, which is a bashism. Delegate netfirc parameter parsing to xargs(1) and awk(1). The potential for code injection is thus eliminated, to the extent that is currently possible in netifrc. It also eliminates potential issues pertaining to word splitting and unintentional pathname expansion. Add additional sanity checks and increase the rigour of those that exist. For instance, blank values are no longer permitted and the tunnel_id parameter must match that of l2tpsession_*, in the case that l2tptunnel_* is defined. Add additional diagnostic messages while improving the clarity of those that already existed. This is achieved in some instances by being more precise and, in others, through the use of English that exhibits greater formality and consistency. At least one grammatical error was rectified. Simplify and refine the code in terms of both structure and syntax, and greatly reduce the number of (local) variables. As a byproduct, all complaints previously raised by shellcheck have been eliminated, save for the use of local, whose behaviour is not defined by POSIX. I have not attempted to eliminate the use of local because, for now, it continues to be used extensively throughout the netifrc codebase. Honour the exit status value of ip(8) for the "add" and "del" verbs, rather than parse STDERR. Optimise l2tp_post_stop() by refraining from executing ip(8) and awk(8) in the case that the interface cannot be identifed as a virtual one. Further, do not attempt to destroy the tunnels associated with an identified session in the case that the attempt to destroy the session has failed. Signed-off-by: Kerin Millar <kfm@plushkava.net> Bug: https://bugs.gentoo.org/890238 Signed-off-by: Sam James <sam@gentoo.org>
* net/hsr: add Parallel Redundancy Protocol (PRP) supportRobin H. Johnson2022-12-251-1/+6
| | | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> Reference: https://github.com/gentoo/netifrc/pull/38
* Adding the saved args to the stop commandkmartin362022-12-251-2/+2
| | | | | | | | Closes: https://bugs.gentoo.org/881039 Signed-off-by: Kevin Martin <kevinmbecause@gmail.com> (cherry picked from commit 0e1c19959a6d82accdb57fa7a1f5b0036037a001) Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> Closes: https://github.com/gentoo/netifrc/pull/41
* net/ethtool: support more ethtool config knobsRobin H. Johnson2021-04-051-2/+13
| | | | | | | | | | | | | | Additional options now supported: --set-channels --set-dump --set-fec --set-phy-tunable --set-priv-flags --set-rxfh-indir --per-queue --features Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* Merge remote-tracking branch 'github/pr/36'Robin H. Johnson2021-04-051-2/+2
|\ | | | | | | | | Closes: https://github.com/gentoo/netifrc/pull/36 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
| * net/ethtool.sh: add "eee" and "tunable" setting operationsMaciej S. Szmigiero2021-03-271-2/+2
| | | | | | | | | | | | | | This adds an ability to set "eee" and "tunable" ethtool parameters of a network interface. Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
* | net/iproute2.sh: in _get_mac_address, don't return multiple addressesPatrick McLean2021-03-301-3/+2
|/ | | | | | | | | | | | | Currently if a device has virtual functions configured, ip will list the mac addresses for the virtual functions on a device as well as the device itself. This makes _get_mac_address return these addresses as well, causing functions that consume this output to fail in "interesting" ways. This makes sure it only returns 1 address. Also don't set the mac variable to the address of the interface from sysfs, then proceed to overwrite it with a call to "ip". Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
* net/dummy.sh: Add support for network namespacesPatrick McLean2021-03-111-7/+9
| | | | | Closes: https://github.com/gentoo/netifrc/pull/35 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/bridge.sh: Add support for network namespaces when using iproute2Patrick McLean2021-03-111-14/+14
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/bonding.sh: Add support for network namespacesPatrick McLean2021-03-111-26/+31
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/iproute2.sh: Add initial support for network namespacesPatrick McLean2021-03-111-47/+101
| | | | | | | | | | | | | | | | | | This adds initial support for network namespaces. An interface can be assigned to a network namespace with `netns_${IFACE}`. The script will move the interface to the namespace if it is not already there. This adds a helper functions to `functions.sh` called `_netns`, this function facilitates scripts working withing network namespaces. It allows eching to sysfs etc files, globbing, and arbitrary commands within a network namespace. This uses a wrapper for the `ip` command so all calls to it will add `-n ${netns}` so it's operating in the netns. Basic interface configuration is tested and working. Signed-off-by: Patrick McLean <chutzpah@gentoo.org> Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/apipa.sh: Simplify and address the remaining portability issuesKerin Millar2021-02-021-34/+29
| | | | | | | | | | | | | | | | | | | | | | Re-factor the over-generalised seeding function into a _random_uint16 function. Have it use a simpler, faster method to collect entropy, with the aid of od(1). Shorten the previously rambling comment. Simplify the _random_apipa_octets function. Clamp the seed to the range 0-32767 for maximal portability. Convey the seed as a formal parameter, rather then inject it. Use a simpler method to produce the octets, running awk(1) only once. Format the random float, so that awk(1) is prevented from using scientific notation to represent certain numbers. Change a variable name in the subshell responsible for reading the list of octet pairs, so as to be less confusing to future readers. Note that the portability issue mentioned by commit 31a05f1 is addressed. The code should now be fully POSIX-compliant, save for the continued use of the local keyword, upon which it does not rely. Signed-off-by: Kerin Millar <kfm@plushkava.net> Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/apipa.sh: Account for the first and last /24 being reservedKerin Millar2021-01-271-3/+3
| | | | | | | | | | While the 169.254/16 prefix is used to define IPv4 link-local addresses, RFC 3927 states that the first 256 and last 256 addresses are reserved for future use. Therefore, the number of available addresses amounts to neither 64516 nor 65534, but actually 65024. Signed-off-by: Kerin Millar <kfm@plushkava.net> Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/iwd.sh: Removed non-working "need dbus" callLars Wendler2021-01-271-1/+0
| | | | | | | This is a copy-paste remnant from net/wpa_supplicant.sh which never worked with standalone netifrc. Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/apipa.sh: fix broken implementation by way of a rewriteKerin Millar2021-01-271-27/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sadly, the present implementation has never functioned correctly. The original author employed incorrect syntax for what was intended to be a command substitution. As a result, the _random() function is never called. What actually happens is that arping is needlessly executed exactly 64516 times, with no address ever being considered as a valid candidate. Furthermore, this module has other bugs and is poorly designed. Here are the reasons as to why:- • the 169.254.0.0/16 block offers 65534 addresses, not 64516 • the main loop is horrendously slow at enumerating the address block • it counts to 64516 but doesn't ensure that each address is unique! • it prefers bash for generating entropy (fine, but non-standard) • it falls back to a non-standard utility for generating entropy Therefore, I decided to re-write most of it. The fundamental difference is that all 65534 octet pairs are generated up front before being processed by the main loop. At most, every possible address will now be tested exactly once. In fact, this approach turns out to be faster by an order of magnitude. The following synthetic tests - which calculate the time taken to enumerate the entire address space - demonstrate the tremendous difference between the existing code and mine. Of course, to ensure that the comparison was meaningful, I rectified the command substitution bug in the existing code. # time bash apipa-old-test.sh real 2m34.367s user 1m9.959s sys 1m37.502s # time bash apipa-new-test.sh real 0m1.119s user 0m0.965s sys 0m0.182s Note that the new _random_apipa_octets() function is responsible for generating all 65534 combinations of octet pairs in a random order. It mainly relies on awk(1) and sort(1). Where possible, a seed is obtained from /dev/urandom for the benefit of awk's RNG, but this is not required. I have isolated and tested the new functions on GNU/Linux, macOS, FreeBSD, NetBSD, OpenBSD and MirBSD. I have individually tested gawk, mawk, nawk, busybox awk and the awk implementations provided by the previously mentioned operating systems in the case that they are distinct. The only incompatiblity that I was personally able to find was with the awk implementation of MirBSD, which affects the final invocation of awk in the _random_apipa_octets function. However, MirBSD was forked from an old version of OpenBSD and seems sufficiently obscure so as not to be worth worrying about. If someone should try to integrate netifrc into MirBSD one day then the matter can be dealt with then. Finally, I want to thank Steve Arnold for bringing the original bug to my attention. Congratulations, Steve. You may be the only known user of net/apipa.sh on the planet. Signed-off-by: Kerin Millar <kfm@plushkava.net> Reported-by: Steve Arnold <nerdboy@gentoo.org> Closes: https://bugs.gentoo.org/766890 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* Use sysfs to obtain the MAC address in net/iproute2.shKerin Millar2021-01-241-9/+6
| | | | | | | | | | | | Dispense with the hideous ip-link(8) parser. Instead, collect the MAC address by reading from the relevant sysfs file. While at it, tidy up the remainder of the function so that the control flow is easier to ascertain at a glance. Note that the address will be rendered in upper case, just as it was before. Signed-off-by: Kerin Millar <kfm@plushkava.net> Closes: https://bugs.gentoo.org/766758 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/wpa_supplicant.sh: Removed non-working "need dbus" callLars Wendler2021-01-181-8/+0
| | | | | | | | | | This is a remnant from when netifrc was part of openrc. After netifrc became it's own standalone project, the call "need dbus" got caught by the need() function from openrc's sh/openrc-run.sh script which does a simple echo on every input it receives. Bug: https://bugs.gentoo.org/622730 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/pppd.sh: Completely overhauled pppd version checkLars Wendler2021-01-181-21/+3
| | | | | | | Thanks-to: Kerin Millar <kfm@plushkava.net> Bug: https://bugs.gentoo.org/729920 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* Convert many "grep" calls to "grep -F"Lars Wendler2021-01-185-11/+9
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/pppd.sh: Improved pppd version checkLars Wendler2021-01-181-1/+1
| | | | | | | | | | | Ed Wildgoose reported an issue with pppd version check if plugins are also to be initialized. I this case "pppd --version" also reports the plugins and that can confuse our original version check. Bug: https://bugs.gentoo.org/729920 Thanks-to: Ed Wildgoose <ed+git@wildgooses.com> Closes: https://github.com/gentoo/netifrc/pull/33 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/l2tp.sh: dash doesn't know "&>/dev/null" redirectLars Wendler2021-01-181-2/+1
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/pppd.sh: prefer defaultroute-metricLars Wendler2021-01-051-2/+2
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/pppd.sh: ppp-2.4.9 has renamed rp-pppoe.so to pppoe.soLars Wendler2021-01-051-4/+3
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* Add code style fixes and missing copyright headersLars Wendler2021-01-051-2/+3
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/dhcpcd.sh: Remove support for ancient dhcpcd versionsLars Wendler2021-01-051-18/+9
| | | | Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/dhcpcd.sh: Don't run dhcpcd on stop if it's not installedBrian Evans2020-12-151-1/+1
| | | | | Bug: https://bugs.gentoo.org/760093 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
* net/iw: implement 802.11s meshRobin H. Johnson2020-06-021-0/+25
| | | | | Closes: https://bugs.gentoo.org/469296 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/iw: refactor iw mode setupRobin H. Johnson2020-06-021-17/+20
| | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* dhclientv6: Add DHCPv6 support via dhclientDaniel Solano Gómez2020-06-024-6/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds DHCPv6 support to OpenRC in Linux using dhclient as outlined by Stuart Longland at <http://stuartl.longlandclan.yi.org/blog/2011/02/15/gentoo-and-dhcpv6/>. The main place where the new support is added is via a modified copy of the dhclient.sh script that: - Renames functions using a 'v6' suffix - Uses a different pid file - Uses the '-6' argument when invoking dhclient - Recognizes new DHCPv6-specific configuration variables with a fallback to the DHCP configuration variables. Additionally: 1. The iproute2 and Linux ifconfig scripts have been ammended to be able to return IPv6 addresses using new '_get_inet6_address' and '_get_inet6_addresses' functions. 2. The 'net.lo' init script now has a '_show_address6' function. 3. The documentation in the Linux net.example now contains some DHCPv6 information. Reported-by: Dustin C. Hatch <admiralnemo@gmail.com> X-Gentoo-Bug: 150908 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=150908 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> (cherry picked from commit bd7bd3a513c8ddc554e211316c990b5f98110982) Closes: https://bugs.gentoo.org/450326 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* Added macvtap supportArseni Nimera2020-05-311-2/+6
| | | | | | | Bug: https://bugs.gentoo.org/691372 Signed-off-by: Arseni Nimera <shorrer@yandex.by> (cherry picked from commit 0dc79645173fad82e0d437a6569b7ea7fa356197) Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/ip6to4: partial fix for bug #528314Robin H. Johnson2020-05-301-2/+2
| | | | | | | | netifrc has never clearly documented exactly what shell is targeted, and this bug does not occur on any shell that supports the 'local' keyword. Reference: https://bugs.gentoo.org/528314 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/iproute2: support containers without /proc/sys/net/ipv4/route/flushRobin H. Johnson2020-05-301-1/+11
| | | | | Bug: https://bugs.gentoo.org/648600 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/iwd: ensure program is presentRobin H. Johnson2020-05-301-0/+1
| | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/iwd: add iwd helperHans Fernhout2020-05-301-0/+53
| | | | | Bug: https://bugs.gentoo.org/690808 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/dhcpcd.sh: Put user args into a temp fileLars Wendler2020-05-301-6/+14
| | | | | | | | So we still use the correct PID even if the user has changed his configuration between start and stop. Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/dhcpcd.sh: fetch pidfile location from dhcpcdLars Wendler2020-05-301-2/+11
| | | | | | | | | There's a -P switch for this but we also need to take into account the -4 and -6 switches as they both alter the pidfile's name. Bug: https://bugs.gentoo.org/718114 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* shellcheck: fix Double quote array expansions to avoid re-splitting ↵0.7.0Robin H. Johnson2020-01-042-2/+2
| | | | | | elements. [SC2068] Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* pppd.sh: ppp-2.4.8 introduced "defaultroute-metric" optionLars Wendler2020-01-031-2/+32
| | | | | | | | | | That option name differs from the one we patched into previous pppd releases so check if we are on >=2.4.8 version and use the correct option name accordingly Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> Closes: https://bugs.gentoo.org/704722 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/iw.sh: minor whitespace fixBen Kohler2019-07-091-2/+2
| | | | Signed-off-by: Ben Kohler <bkohler@gentoo.org>
* net/*: fix ordering of dhcp clientsBen Kohler2019-07-093-2/+8
| | | | | | | | We want to prefer dhclient over busybox udhcpc if it's available. This commit also adds deps to the other services which will guarantee the priority dhcpcd > dhclient > pump > udhcpc. Signed-off-by: Ben Kohler <bkohler@gentoo.org>
* net/system.sh: change net-scripts to netifrc in outputBen Kohler2019-07-091-3/+3
| | | | Signed-off-by: Ben Kohler <bkohler@gentoo.org>
* Add shellcheck toolingRobin H. Johnson2019-04-2040-0/+40
| | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* Two separate peer variables for every peer in vethKirill Semenkov2019-04-201-24/+11
| | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* Veth support addedKirill Semenkov2019-04-201-1/+1
| | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* Veth support addedKirill Semenkov2019-04-201-0/+193
| | | | Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/wireguard: import from ebuildRobin H. Johnson2018-07-111-1/+2
| | | | | | | | | | | This improves non-maintainer commit 66af4525ff3a4530a165443f459134f1f60283f8 to include correct author attribution for net/wireguard.sh, as traced & discussed with the upstream author. Original-Author: Joakim Sindholt <opensource@zhasha.com> Signed-off-by: Jason A. Donenfeld <zx2c4@gentoo.org> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/wireguard: import from ebuildJason A. Donenfeld2018-07-102-1/+54
| | | | Signed-off-by: Jason A. Donenfeld <zx2c4@gentoo.org>
* net/iproute2: improve DAD tentative wait/output.Robin H. Johnson2018-01-211-6/+14
| | | | | | | | | | | | | | If an interface had dad_timeout=0 set, then the wait loop output is confusing. Skip it entirely, printing a useful message: > Not waiting for DAD timeout on tentative IPv6 addresses (per conf.d/net dad_timeout) Refactor the DAD tentantive conditionals for ease of debugging. Bug 636846 suggests that some kernels are still showing tentative addresses despite sysctls being set. Bug: https://bugs.gentoo.org/636846 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/wpa_supplicant: rewrite -D detectionRobin H. Johnson2017-11-271-5/+15
| | | | | | | | | | | | Commit 38b9fac9 per Henning Schild's submission PR#27 improved wpa_supplicant driver detection, but had room for improvements as discussed in the comment thread. Includes detection of -N for future multiple interface work. Bug: https://github.com/gentoo/netifrc/pull/27 CC: Henning Schild <henning@hennsch.de> Thanks-To: Henning Schild <henning@hennsch.de> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
* net/wpa_supplicant: change how we match wired connectionsHenning Schild2017-11-271-4/+5
| | | | | | | | | | | Before that patch you needed to write "-Dwired" in /etc/conf.d/net. Where in fact "-D wired" or even a string with multiple spaces would be ok for wpa_supplicant. Signed-off-by: Henning Schild <henning@hennsch.de> Closes: https://github.com/gentoo/netifrc/pull/27 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> (cherry picked from commit f5b82067ee5ce9badf328c92723e36a86588e74d)