Commit Graph

34 Commits

Author SHA1 Message Date
Lennart Poettering ae2a15bc14 macro: introduce TAKE_PTR() macro
This macro will read a pointer of any type, return it, and set the
pointer to NULL. This is useful as an explicit concept of passing
ownership of a memory area between pointers.

This takes inspiration from Rust:

https://doc.rust-lang.org/std/option/enum.Option.html#method.take

and was suggested by Alan Jenkins (@sourcejedi).

It drops ~160 lines of code from our codebase, which makes me like it.
Also, I think it clarifies passing of ownership, and thus helps
readability a bit (at least for the initiated who know the new macro)
2018-03-22 20:21:42 +01:00
Rosen Penev 1e35c5ab27 systemd-link: Remove UDP Fragmentation Offload support. (#8183)
Support was killed in kernel 4.15 as well as ethtool 4.13.

Justification was lack of use by drivers and too much of a maintenance burden.
https://www.spinics.net/lists/netdev/msg443815.html

Also moved config_parse_warn_compat to conf-parser.[ch] to fix compile errors.
2018-03-18 14:28:14 +01:00
Lennart Poettering 6b44a121c1 cocci: there's not ENOTSUP, there's only EOPNOTSUPP
On Linux the former is a compat alias to the latter, and that's really
weird, as inside the kernel the two are distinct. Which means we really
should stay away from it.
2018-01-11 15:12:16 +01:00
Lennart Poettering 2b44daaa20 ethtool-util: don't pass fds as pointers if we don't have to
Passing them as pointers is just weird, hence don't do it
2018-01-11 15:12:16 +01:00
Lennart Poettering 20d4e99524 ethtool-util: fix weird whitespace 2018-01-11 15:12:16 +01:00
Lennart Poettering ab1263d774 ethtool-util: order includes properly 2018-01-11 15:12:16 +01:00
Lennart Poettering 89e1ba0ab2 ethtool-util: no need for memcpy() where normal assignment works too 2018-01-11 15:12:16 +01:00
Bruce A. Johnson 94d4acbe4b systemd-udevd: fix speed/duplex processing with valid .link files (#7808)
Including BitsPerSecond or Duplex values in .link files did not work when
set_slinksettings was called because the routine was not copying the base
parameters to the structure given to ioctl.  As a result, EINVAL was always
reported, and no change occurred on the Ethernet device.
2018-01-05 10:02:38 +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
Susant Sahani ffa69a04be systemd-link: Add support to configure tx-tcp6-segmentation (#6859)
closes #6854

tcp-segmentation-offload: off
	tx-tcp-segmentation: off
	tx-tcp-ecn-segmentation: off [fixed]
	tx-tcp-mangleid-segmentation: off
	tx-tcp6-segmentation: off <==========================
2017-09-19 10:49:58 +02:00
Susant Sahani 617da14cfd systemd-link: ethtool add support for more Wake up Lan setting (#6331)
This works supports to configure nicast, multicast, broadcast, arp and SecureOn.
2017-08-31 12:44:43 +02:00
Susant Sahani 9c5e117239 ethtool: Fix speed in 593022fa37
We should use the DIV_ROUND_UP
2017-06-26 18:37:38 +05:30
Susant Sahani 593022fa37 systemd-link: add support to configure the device port (#6153)
This work allows to configure device port:

tp — An Ethernet interface using Twisted-Pair cable as the medium.
aui — Attachment Unit Interface (AUI). Normally used with hubs.
bnc — An Ethernet interface using BNC connectors and co-axial cable.
mii — An Ethernet interface using a Media Independent Interface (MII).
fibre — An Ethernet interface using Optical Fibre as the medium.
2017-06-25 18:42:57 -04:00
Susant Sahani a39f92d391 Link: port to new ethtool ETHTOOL_xLINKSETTINGS
Link: port to new ethtool ETHTOOL_xLINKSETTINGS
This patch defines a new ETHTOOL_GLINKSETTINGS/SLINKSETTINGS API,
handled by the new get_link_ksettings/set_link_ksettings .

This is a WIP version based on this [kernel
patch](https://patchwork.kernel.org/patch/8411401/).

commit 0527f1c

3f1ac7a700ommit
35afb33
2016-11-10 15:12:56 +05:30
Lennart Poettering 429b435026 sd-device/networkd: unify code to get a socket for issuing netdev ioctls on
As suggested here:

https://github.com/systemd/systemd/pull/4296#issuecomment-251911349

Let's try AF_INET first as socket, but let's fall back to AF_NETLINK, so that
we can use a protocol-independent socket here if possible. This has the benefit
that our code will still work even if AF_INET/AF_INET6 is made unavailable (for
exmple via seccomp), at least on current kernels.
2016-10-06 19:04:01 +02:00
Susant Sahani a9dee27f0d fix #4080
ethtool_sset_info  adding some extra space to it.

also fix valgrind warning
```
Unloaded link configuration context.
==31690==
==31690== HEAP SUMMARY:
==31690==     in use at exit: 8,192 bytes in 2 blocks
==31690==   total heap usage: 431 allocs, 429 frees, 321,164 bytes allocated
==31690==
==31690== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 2
==31690==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==31690==    by 0x166B32: mempool_alloc_tile (mempool.c:62)
==31690==    by 0x166BBC: mempool_alloc0_tile (mempool.c:81)
==31690==    by 0x15B8FC: hashmap_base_new (hashmap.c:732)
==31690==    by 0x15B9F7: internal_hashmap_new (hashmap.c:766)
==31690==    by 0x151291: conf_files_list_strv_internal (conf-files.c:103)
==31690==    by 0x1514BA: conf_files_list_strv (conf-files.c:135)
==31690==    by 0x13A1CF: link_config_load (link-config.c:227)
==31690==    by 0x135B68: builtin_net_setup_link_init
(udev-builtin-net_setup_link.c:77)
==31690==    by 0x1306B3: udev_builtin_init (udev-builtin.c:57)
==31690==    by 0x11E984: adm_builtin (udevadm-test-builtin.c:72)
==31690==    by 0x117B4D: run_command (udevadm.c:75)
```
Fixes #4080
2016-09-02 16:06:58 +05:30
Susant Sahani f7ea90fbba link : add support to configure LRO and GRO Offload features
The patch supports to configure

GenericReceiveOffload
LargeReceiveOffload
2016-08-31 12:47:02 +05:30
Susant Sahani 50725d10e3 link : add support to configure Offload features (#4017)
This patch supports these features to be on or off

Generic Segmentation Offload
TCP Segmentation Offload
UDP Segmentation Offload

fixes #432
2016-08-30 16:52:04 +02:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering 8b43440b7e util-lib: move string table stuff into its own string-table.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering ece174c543 tree-wide: drop {} from one-line if blocks
Patch via coccinelle.
2015-09-09 08:20:20 +02:00
Susant Sahani 61087906e0 udev: fix coding style 2015-05-06 09:27:46 -07:00
Michal Schmidt f647962d64 treewide: yet more log_*_errno + return simplifications
Using:
find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
 'local $/;
  local $_=<>;
  s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg;
  print;'
 $f
done

And a couple of manual whitespace fixups.
2014-11-28 18:56:16 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Tom Gundersen aedca89268 udev: net_setup_link - open ethtool and rtnl connections lazily 2014-09-09 15:36:56 +02:00
Daniel Mack 2c5859afec Make tables for DEFINE_STRING_TABLE_LOOKUP consistent
Bring some arrays that are used for DEFINE_STRING_TABLE_LOOKUP() in the
same order than the enums they reference.

Also, pass the corresponding _MAX value to the array initalizer where
appropriate.
2014-03-07 21:38:48 +01:00
Tom Gundersen 6c0519c012 net: initialize structs when declaring 2014-02-21 21:32:38 +01:00
Lennart Poettering 61f3af4fed net: initialize structs when declaring them/do not clobber caller variables
Just two minor style fixes...
2014-02-21 21:23:40 +01:00
Tom Gundersen 847a8a5fed udev - link-setup - expose ID_NET_DRIVER
This is the same as shown by 'ethtool -i <ifname>', and is sometimes
set even though DRIVER is not.
2014-02-21 21:00:39 +01:00
Michal Sekletar 0a2c229426 net-util: call ioctl() only if necessary
In case when update of current values is not necessary we still might end up
calling ioctl(), because need_update variable is not explicitly initialized.
2013-11-07 22:25:42 +01:00
Tom Gundersen 2a7e74e002 udev: link-config - use zero instead of memset 2013-10-29 16:12:12 +01:00
Tom Gundersen 5fde13d748 udev: link-config - add proper parsing 2013-10-29 14:17:57 +01:00
Tom Gundersen a501033335 udev: link-config: add ethtool support
This adds support for setting the link speed, duplex and WakeOnLan
settings.

Example:

[Link]
SpeedMBytes=100
Duplex=half
WakeOnLan=magic
2013-10-26 22:09:20 +02:00