Commit graph

130 commits

Author SHA1 Message Date
Lennart Poettering 760877e90c util: split out sorting related calls to new sort-util.[ch] 2019-03-13 12:16:43 +01:00
Yu Watanabe c9cc038343 network: introduce 'degraded-carrier' operstate to order all states
Previously, 'degraded' state is ambiguous for bonding or bridge master:
1. one or more slave interfaces does not have carrier,
2. no link local address is assigned to the master,
3. combination of the above two.

This makes the above case 1 and 3 are in the new 'degraded-carrier'
state, and makes 'degraded' state as all slaves are active but no
link local address on master.
2019-03-13 14:29:00 +09:00
Yu Watanabe 85323805be networkctl: make enslaved operstate green 2019-02-18 18:04:18 +09:00
Yu Watanabe a696290474 networkctl: accept wildcards to specify links
Closes #10840.
2019-02-15 13:47:48 +09:00
Lennart Poettering 9a6f746fb6 locale-util: prefix special glyph enum values with SPECIAL_GLYPH_
This has been irritating me for quite a while: let's prefix these enum
values with a common prefix, like we do for almost all other enums.

No change in behaviour, just some renaming.
2018-12-14 08:22:54 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Zbigniew Jędrzejewski-Szmek 4e2ca44233 networkctl: define main through macro 2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00
Yu Watanabe 2c740afd16 tree-wide: do not assign unused return values 2018-09-23 17:18:50 +09:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
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.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
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.
2018-06-14 10:20:20 +02:00
Filipe Brandenburger d23c3e4c28 lldp: check that lldp neighbor raw data size is in expected range
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.
2018-06-08 08:54:25 +02:00
Lennart Poettering 4e964aa05c networkd,udev: clean up MTU handling
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.)
2018-04-26 13:51:44 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
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.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Yu Watanabe ee5324aa04 tree-wide: voidify pager_open()
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.
2018-03-19 21:04:02 +09:00
Yu Watanabe 15c3626e06 networkctl,hwdb: make verbs static 2018-03-19 21:03:35 +09:00
Jason A. Donenfeld b55822c349 networkd: clean up link_get_type_string returns
It's cleaner and more consistent to actually return what we were
planning on returning.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 21:08:39 +01:00
Jason A. Donenfeld fdce7817b9 networkd: clean up link_get_type_string
The return value is always ignored, so get rid of it.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-01-29 21:06:28 +01:00
Jason A. Donenfeld f119082e7a networkd: simplify and display all devtypes
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>
2018-01-29 21:02:44 +01:00
Jason A. Donenfeld a18461bc7d networkd: display wireguard devtype
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>
2018-01-29 20:58:30 +01:00
Lennart Poettering fbd0b64f44
tree-wide: make use of new STRLEN() macro everywhere (#7639)
Let's employ coccinelle to do this for us.

Follow-up for #7625.
2017-12-14 19:02:29 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Yu Watanabe 4c70109600 tree-wide: use IN_SET macro (#6977) 2017-10-04 16:01:32 +02:00
Susant Sahani d37b7627c2 networkctl: display address labels
```
 ./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

```
2017-06-27 10:15:27 -04:00
Zbigniew Jędrzejewski-Szmek 1cf03a4f8e systemctl,networkctl,busctl,backlight: use STRPTR_IN_SET 2016-09-24 20:22:05 -04:00
Zbigniew Jędrzejewski-Szmek 323b7dc903 tree-wide: rename draw_special_char to special_glyph
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.
2016-05-09 15:17:57 -04:00
Beniamino Galvani 6afa676780 lldp: move public macros to sd-lldp.h and namespace them
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.
2016-03-24 16:41:48 +01:00
Zbigniew Jędrzejewski-Szmek 2388b2f4d4 networkctl: avoid reading past end of input buffer
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.
2016-03-04 21:45:45 -05:00
Zbigniew Jędrzejewski-Szmek 72e551f40b networkctl: use ETHER_ADDR_NULL in one more place 2016-03-04 21:45:45 -05:00
Zbigniew Jędrzejewski-Szmek 06fb28b16e Merge pull request #2671 from 0xAX/move-pager-open-to-one-place
tree-wide: merge pager_open_if_enabled() to the pager_open()
2016-02-25 15:29:59 -05:00
Alexander Kuleshov ea4b98e657 tree-wide: merge pager_open_if_enabled() to the pager_open()
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.
2016-02-26 01:13:23 +06:00
Thomas Hindoe Paaboel Andersen 404d53a968 networkctl: fix const 2016-02-23 20:40:51 +01:00
Zbigniew Jędrzejewski-Szmek 4c3160f150 networkctl: only print lldp legend for capabilities that were actually seen 2016-02-23 08:50:52 -05:00
Lennart Poettering d08191a242 networkctl: ellipsize long LLDP fields in table output 2016-02-21 20:58:59 +01:00
Lennart Poettering f5207c2206 networkctl: add missing newline to printf() format string 2016-02-21 20:58:59 +01:00
Lennart Poettering 58fb367825 networkctl: print a nice warning when networkd isn't running 2016-02-21 20:40:57 +01:00
Lennart Poettering 33d5013db0 networkctl: if there's no data from networkd about an iface show as "unmanaged"
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.)
2016-02-21 20:40:57 +01:00
Lennart Poettering 4abd866d68 networkctl: add a couple of (void) casts
Where we knowingly ignore possible error results, let's cast to void.
2016-02-21 20:40:57 +01:00
Lennart Poettering b295beea88 networkd: rework how carrier bindings are serialized
Instead of serializing the interface name, expose the interface index, since
that's the only stable identifier.
2016-02-21 20:40:57 +01:00
Lennart Poettering 837f57da41 networkctl: extend "networkctl status" per-interface output to include LLDP info
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.
2016-02-21 20:40:57 +01:00
Lennart Poettering 691d4da98a networkctl: make use of xsprintf() where we can 2016-02-21 20:40:57 +01:00
Lennart Poettering 7e5a080a94 networkctl: simplify networkctl
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().
2016-02-21 20:40:57 +01:00
Lennart Poettering b147503eb4 networkctl: rework interface data acquisition
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.
2016-02-21 20:40:57 +01:00
Lennart Poettering e997c4b09d networkctl: extend "networkctl list" and "networctl lldp" to optionally take interface names
This way, the output may be reduced to only show data about the specified
interfaces.
2016-02-21 20:40:57 +01:00
Lennart Poettering 7d367b45f6 networkctl: add new call that unifies link data acquisition between "status" and "lldp" verbs 2016-02-21 20:40:57 +01:00
Lennart Poettering 1fb82beb38 networkctl: fix dispatch_verb() table
VERB_DEFAULT may only appear once.
2016-02-21 20:40:57 +01:00
Lennart Poettering 0070333f26 networkctl: split out system status stuff into its own function 2016-02-21 20:40:56 +01:00