summaryrefslogtreecommitdiff
path: root/src/network/networkctl.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* lldp: check that lldp neighbor raw data size is in expected rangeFilipe Brandenburger2018-06-081-0/+4
| | | | | | | | | This fixes an insecure use of tainted data as argument to functions that allocate memory and read from files, which could be tricked into getting networkctl to allocate a large amount of memory and fill it with file data. This was uncovered by Coverity. Fixes CID 1393254.
* networkd,udev: clean up MTU handlingLennart Poettering2018-04-261-1/+1
| | | | | | | | | | | | | | | | This cleans up handling of MTU values across the codebase. Previously MTU values where stored sometimes in uint32_t, sometimes in uint16_t, sometimes unsigned and sometimes in size_t. This now unifies this to uint32_t across the codebase, as that's what netlink spits out, and what the majority was already using. Also, all MTU parameters are now parsed with config_parse_mtu() and config_parse_ipv6_mtu() is dropped as it is now unneeded. (Note there is one exception for the MTU typing: in the DCHPv4 code we continue to process the MTU as uint16_t value, as it is encoded like that in the protocol, and it's probably better stay close to the protocol there.)
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-4/+2
|
* tree-wide: voidify pager_open()Yu Watanabe2018-03-191-3/+3
| | | | | | Even if pager_open() fails, in general, we should continue the operations. All erroneous cases in pager_open() show log message in the function. So, it is not necessary to check the returned value.
* networkctl,hwdb: make verbs staticYu Watanabe2018-03-191-5/+5
|
* networkd: clean up link_get_type_string returnsJason A. Donenfeld2018-01-291-19/+9
| | | | | | | It's cleaner and more consistent to actually return what we were planning on returning. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* networkd: clean up link_get_type_stringJason A. Donenfeld2018-01-291-9/+7
| | | | | | The return value is always ignored, so get rid of it. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* networkd: simplify and display all devtypesJason A. Donenfeld2018-01-291-20/+3
| | | | | | | | | | | | | | Every place the kernel actually calls SET_NETDEV_DEVTYPE, it's adding a piece of information that looks useful and relevant for us to use. So let's use it when it's there. The previous matching based on the corresponding ARPHRD didn't really make much sense. The more sensible logic for getting a textual representation of the link type is to see if the kernel supplies a devtype. If it does, great. If not, then we can fall back on the ARPHRD, as before. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* networkd: display wireguard devtypeJason A. Donenfeld2018-01-291-7/+15
| | | | | | | It's not useful to simply show "none", when we have more interesting information to display. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-1/+1
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-1/+1
|
* networkctl: display address labelsSusant Sahani2017-06-271-0/+74
| | | | | | | | | | | | | | | | | | | ``` ./networkctl label Prefix/Prefixlen Label ::/0 1 fc00::/7 5 fec0::/10 11 2002::/16 2 3ffe::/16 12 2001:10::/28 7 2001::/32 6 ::ffff:0.0.0.0/96 4 ::/96 3 ::1/128 0 ```
* systemctl,networkctl,busctl,backlight: use STRPTR_IN_SETZbigniew Jędrzejewski-Szmek2016-09-241-1/+1
|
* tree-wide: rename draw_special_char to special_glyphZbigniew Jędrzejewski-Szmek2016-05-091-2/+2
| | | | | | | | | That function doesn't draw anything on it's own, just returns a string, which sometimes is more than one character. Also remove "DRAW_" prefix from character names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't draw anything, and are always used as an argument to special_glyph(). Rename "DASH" to "MDASH", as there's more than one type of dash.
* lldp: move public macros to sd-lldp.h and namespace themBeniamino Galvani2016-03-241-1/+0
| | | | | | lldp.h contains definitions of LLDP types, subtypes and capabilities which should be exposed in public headers. Get rid of the file and move those definitions to sd-lldp.h with the SD_ prefix.
* networkctl: avoid reading past end of input bufferZbigniew Jędrzejewski-Szmek2016-03-041-1/+2
| | | | | | | | name is IFNAMSIZ bytes, but we would copy sizeof(info->name) bytes, which is IFNAMSIZ + 1. In effect we would go outside of the source buffer and possibly leave a non-null terminated string in info->name. CID #1351754.
* networkctl: use ETHER_ADDR_NULL in one more placeZbigniew Jędrzejewski-Szmek2016-03-041-2/+1
|
* Merge pull request #2671 from 0xAX/move-pager-open-to-one-placeZbigniew Jędrzejewski-Szmek2016-02-251-11/+3
|\ | | | | tree-wide: merge pager_open_if_enabled() to the pager_open()
| * tree-wide: merge pager_open_if_enabled() to the pager_open()Alexander Kuleshov2016-02-261-11/+3
| | | | | | | | | | | | | | | | | | Many subsystems define own pager_open_if_enabled() function which checks '--no-pager' command line argument and open pager depends on its value. All implementations of pager_open_if_enabled() are the same. Let's merger this function with pager_open() from the shared/pager.c and remove pager_open_if_enabled() from all subsytems to prevent code duplication.
* | networkctl: fix constThomas Hindoe Paaboel Andersen2016-02-231-1/+1
| |
* | networkctl: only print lldp legend for capabilities that were actually seenZbigniew Jędrzejewski-Szmek2016-02-231-7/+40
|/
* networkctl: ellipsize long LLDP fields in table outputLennart Poettering2016-02-211-0/+25
|
* networkctl: add missing newline to printf() format stringLennart Poettering2016-02-211-1/+1
|
* networkctl: print a nice warning when networkd isn't runningLennart Poettering2016-02-211-0/+10
|
* networkctl: if there's no data from networkd about an iface show as "unmanaged"Lennart Poettering2016-02-211-2/+6
| | | | | | | | After all, if we know that an interface exists but networkd did not store any info about it, then it's definitely unmanaged by it. (Note that we add this fix-up to networkctl, and not to sd-network, simply because a missing file might also be result of the interface not existing.)
* networkctl: add a couple of (void) castsLennart Poettering2016-02-211-17/+17
| | | | Where we knowingly ignore possible error results, let's cast to void.
* networkd: rework how carrier bindings are serializedLennart Poettering2016-02-211-4/+27
| | | | | Instead of serializing the interface name, expose the interface index, since that's the only stable identifier.
* networkctl: extend "networkctl status" per-interface output to include LLDP infoLennart Poettering2016-02-211-33/+104
| | | | | | | | | | | | | | | This adds a small and useful field to the "systemctl status" output: the router(s) the interface is connected to as reported via LLDP. Example output: ● 2: enp0s25 Link File: /usr/lib/systemd/network/99-default.link Type: ether State: degraded (configured) Path: pci-0000:00:19.0 Driver: e1000e Connected To: GS1900 on port 2 (foobar) i.e. the last line is the relevant one.
* networkctl: make use of xsprintf() where we canLennart Poettering2016-02-211-3/+3
|
* networkctl: simplify networkctlLennart Poettering2016-02-211-62/+52
| | | | | Move decode_and_sort_links() into acquire_info_all() which is the only place this is used. The result is then nicely symmetric to acquire_info_strv().
* networkctl: rework interface data acquisitionLennart Poettering2016-02-211-139/+81
| | | | | | Let's always use the same calls to acquire interface data. Specifically port "networkctl status" to use acquire_link_info_strv() and acquire_link_info_all() like the other calls.
* networkctl: extend "networkctl list" and "networctl lldp" to optionally take ↵Lennart Poettering2016-02-211-41/+110
| | | | | | | interface names This way, the output may be reduced to only show data about the specified interfaces.
* networkctl: add new call that unifies link data acquisition between "status" ↵Lennart Poettering2016-02-211-30/+30
| | | | and "lldp" verbs
* networkctl: fix dispatch_verb() tableLennart Poettering2016-02-211-3/+3
| | | | VERB_DEFAULT may only appear once.
* networkctl: split out system status stuff into its own functionLennart Poettering2016-02-211-31/+36
|
* sd-lldp: rework sd-lldp APILennart Poettering2016-02-211-213/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reworks the sd-lldp substantially, simplifying things on one hand, and extending the logic a bit on the other. Specifically: - Besides the sd_lldp object only one other object is maintained now, sd_lldp_neighbor. It's used both as storage for literal LLDP packets, and for maintainging info about peers in the database. Separation between packet, TLV and chassis data is not maintained anymore. This should be a major simplification. - The sd-lldp API has been extended so that a couple of per-neighbor fields may be queried directly, without iterating through the object. Other fields that may appear multiple times, OTOH have to be iterated through. - The maximum number of entries in the neighbor database is now configurable during runtime. - The generation of callbacks from sd_lldp objects is more restricted: callbacks are only invoked when actual data changed. - The TTL information is now hooked with a timer event, so that removals from the neighbor database due to TTLs now result in a callback event. - Querying LLDP neighbor database will now return a strictly ordered array, to guarantee stability. - A "capabilities" mask may now be configured, that selects what type of LLDP neighbor data is collected. This may be used to restrict collection of LLDP info about routers instead of all neighbors. This is now exposed via networkd's LLDP= setting. - sd-lldp's API to serialize the collected data to text files has been removed. Instead, there's now an API to extract the raw binary data from LLDP neighbor objects, as well as one to convert this raw binary data back to an LLDP neighbor object. networkd will save this raw binary data to /run now, and the client side can simply parse the information. - support for parsing the more exotic TLVs has been removed, since we are not using that. Instead there are now APIs to extract the raw data from TLVs. Given how easy it is to parse the TLVs clients should do so now directly instead of relying on our APIs for that. - A lot of the APIs that parse out LLDP strings have been simplified so that they actually return strings, instead of char arrays with a length. To deal with possibly dangerous characters the strings are escaped if needed. - APIs to extract and format the chassis and port IDs as strings has been added. - lldp.h has been simplified a lot. The enums are anonymous now, since they were never used as enums, but simply as constants. Most definitions we don't actually use ourselves have eben removed.
* sd-netlink: fix ifi_iftype typeLennart Poettering2016-02-201-4/+4
| | | | The iftype is an unsigned short, and not just an unsigned.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* networkctl: move strv_isempty() check into dump_list()Lennart Poettering2016-01-261-36/+26
| | | | | | | | Previously, each invocation of dump_list() was prefixed with a call to strv_isempty() to suppress invocation of the function when the list is empty anyway. Move the check into the function itself, so that we can reduce the code a bit in size. (Also, prefix a couple of invocations we knowingly ignore return errors with a (void) cast).
* networkd: rework Domains= settingLennart Poettering2016-01-261-24/+21
| | | | | | | | | | | | | | | | Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was the "DNS domain" for the network connection, without specifying what that means. With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains=" setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups), while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already implemented before using the "wildcard" domain concept. This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not used by resolved yet, this will be added in a later commit.
* tree-wide: use xsprintf() where applicableDaniel Mack2016-01-121-1/+3
| | | | Also add a coccinelle receipt to help with such transitions.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-1/+0
| | | | Sort the includes accoding to the new coding style.
* networkctl: lldp port to extract_first_wordSusant Sahani2015-11-101-9/+12
|
* parse-util: introduce parse_ifindex() and make use of it everywhereLennart Poettering2015-11-031-1/+1
| | | | | We have enough places where we parse an ifindex, hence introduce a proper parsing function for it, that verifies all parameters.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|