Commit Graph

460 Commits

Author SHA1 Message Date
Tobias Klauser
4deb2ac2cb link/ipgre: Add prototype for ABI-preserving wrapper rtnl_link_get_pmtudisc()
Avoid a GCC -Wmissing-prototypes warning by explicitely adding a
prototype for the ABI-preserving wrapper added in commit 8d04ebf554
("lib/route: preserve old ABI for rtnl_link_get_pmtudisc()") and add an
explanatory comment.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-20 09:38:11 +01:00
Tobias Klauser
80a3877262 link/macsec: Include own public header for function prototypes
Include the own public header in order to get function prototypes for
all public functions defined in this module.

This fixes GCC -Wmissing-prototype warnings

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-20 09:38:11 +01:00
Tobias Klauser
50acd534b3 link/ipvti: Include own public header for function prototypes
Include the own public header in order to get function prototypes for
all public functions defined in this module.

This fixes GCC -Wmissing-prototype warnings.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-20 09:38:10 +01:00
Tobias Klauser
65e268d739 link/ipip: Include own public header for function prototypes
Include the own public header in order to get function prototypes for
all public functions defined in this module.

This fixes GCC -Wmissing-prototype warnings.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-20 09:38:10 +01:00
Tobias Klauser
d0dd6a5125 link/inet6: Include own public header for function prototypes
Include the own public header in order to get function prototypes for
all public functions defined in this module.

This fixes GCC -Wmissing-prototype warnings.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-01-20 09:38:10 +01:00
Nick Kralevich
64b12a065a fopen: add O_CLOEXEC
Add O_CLOEXEC to various fopen() calls. This avoids file descriptors
leaking across an exec() boundary in a multi-threaded program. Please
see "man 2 open" for additional information about O_CLOEXEC.

Signed-off-by: Nick Kralevich <nnk@google.com>

https://github.com/thom311/libnl/pull/128
2017-01-17 23:00:18 +01:00
Thomas Haller
20ed636dee sriov: avoid buffer overrun in rtnl_link_sriov_parse_vflist()
Fixes: 5d6e43ebef

Signed-off-by: Thomas Haller <thaller@redhat.com>
2017-01-17 18:16:11 +01:00
Laine Stump
2d11f40f50 sriov: fix crash in rtnl_link_sriov_parse_vflist
vf_vlan_info was incorrectly indexed with "len" (the length in bytes
of the entire vfinfo_list rather than list_len (the index of the
current end of the vf_vlan_info array)

https://github.com/thom311/libnl/issues/126
http://lists.infradead.org/pipermail/libnl/2017-January/002270.html

Fixes: 5d6e43ebef

Signed-off-by: Thomas Haller <thaller@redhat.com>
2017-01-17 18:03:36 +01:00
Tobias Klauser
e2d8f05bd9 route/tc: Remove unused function tca_set_kind()
The public prototype and the last internal user of the function were
removed in commit 8eb5b5532e ("Unified TC API") and it was unexported in
commit 4280dfb85d ("build: don't export internal symbols"), so it is
safe to remove it.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>

https://github.com/thom311/libnl/pull/122
2017-01-13 18:29:23 +01:00
Thomas Haller
36777bae9a macsec: fix endianness of sci during dump()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-12-15 19:41:19 +01:00
Beniamino Galvani
63088d1fef macsec: document byte order for the SCI and port attributes
Document that the SCI is in network order while the port is in host
order.

Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-12-15 19:41:19 +01:00
Beniamino Galvani
729232bec2 Revert "macsec: fix endianness of 'sci' parameter"
The commit changed the API from libnl 3.2.28: restore the old
behavior.

This reverts commit cd758fbfee.

Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-12-15 19:41:19 +01:00
Thomas Haller
02cccc69bc utils/trivial: rename internal _nl_offset_plus_sizeof() macro to _nl_offsetofend()
Kernel calls a very similar macro "offsetofend". So use that name
as it migth be more familiar to the reader.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-12-15 19:41:06 +01:00
Tobias Klauser
fb32f6e6c0 link: fix documentation for rtnl_link_get_carrier_changes
The doxygen comment of rtnl_link_get_carrier_changes still describes the
initially implemented behaviour and was not updated, when the signature
was changed as part of #119. Adjust it accordingly.

Fixes: 0c4b2ea6d1 ("link: add support for IFLA_CARRIER_CHANGES")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>

https://github.com/thom311/libnl/pull/120
2016-12-06 15:42:25 +01:00
Tobias Klauser
6fc6bef6d0 link: add support for IFLA_GSO_MAX_SEGS and IFLA_GSO_MAX_SIZE
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-06 15:08:42 +01:00
Tobias Klauser
598e35dcd9 link: add support for IFLA_PHYS_SWITCH_ID
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-06 15:08:36 +01:00
Tobias Klauser
1eb0c1c8dc link: add support for IFLA_PHYS_PORT_NAME
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-06 15:08:01 +01:00
Tobias Klauser
0c4b2ea6d1 link: add support for IFLA_CARRIER_CHANGES
Also expose the attribute value via link_dump_details()

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-12-06 14:55:40 +01:00
Sushma Sitaram
993a62d450 route/act: add gact tc action
Signed-off-by: Sushma Sitaram <sushma.sitaram@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>

http://lists.infradead.org/pipermail/libnl/2016-November/002249.html
2016-12-02 13:43:36 +01:00
Thomas Haller
6f96207212 link: set ifi_change flags for rtnl_link_build_add_request()
For the add-request, we should set ifi_change flags together with the
ifi_flags. A similar thing is done by rtnl_link_build_change_request()
in commit 34ccb7210f.

https://github.com/thom311/libnl/issues/111
2016-11-29 22:46:01 +01:00
Thomas Haller
dcc75338f0 lib/route: pass sizeof() argument to nl_memcpy()
nl_memcpy() internally already never copies more then
nla_len(tb). The previous code might overflow if the
netlink attribute is longer then the size of the destination.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-29 12:38:07 +01:00
Tobias Klauser
5040fc8a49 lib/route: add rx_nohandler link stats field
A new counter rx_nohandler was added to the link stats in kernel commit
6e7333d315a7 ("net: add rx_nohandler stat counter"). Wire it up in the
libnl link stats as well.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2016-11-29 09:15:16 +01:00
Sushma Sitaram
90680e024b route/cls: support setting of selector fields
Enables to set the shift, offset, mask and flags of the position to next header

http://lists.infradead.org/pipermail/libnl/2016-September/002227.html
http://lists.infradead.org/pipermail/libnl/2016-October/002232.html

Signed-off-by: Sushma Sitaram <sushma.sitaram@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-28 22:51:03 +01:00
Thomas Haller
4a3cf02a25 ppp: fix API in ppp.h header
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-28 22:24:15 +01:00
Jonas Johansson
0caa3ebbe0 ppp: fix type of file descriptor; uint32_t -> int32_t
Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
2016-11-28 22:14:15 +01:00
Jonas Johansson
d21df4e223 ppp: rename local struct ppp_info* variables; pi -> info
Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
2016-11-28 22:14:15 +01:00
Jonas Johansson
7a0131f752 ppp: update code after review
Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
2016-11-28 22:14:15 +01:00
Jonas Johansson
53fd38d5d4 Add PPP support
This patch add support for kernel PPP interfaces.

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
2016-11-28 22:14:15 +01:00
Thomas Haller
de73a5dc3a lib/route: use _nl_offset_plus_sizeof() macro for minlen field for rtln_link_policy
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-28 21:49:54 +01:00
Tobias Klauser
51a51c3a1c lib/route: keep link stats minlen compatible with kernel < 4.6
Since linux/if_link.h was synced in libnl commit d533736e22 ("vxlan:
add support for additional VXLAN attributes."), the minlen check in
validate_nla() fails on kernels < 4.6 - or more precisely, on kernels
not containing kernel commit 6e7333d315a7 ("net: add rx_nohandler stat
counter"). The check fails because rtnl_link_stats and rtnl_link_stats64
sent by the kernel don't have the rx_nohandler member yet, but libnl
expects them to have it.

Account for this by decreasing the minlen by one member and add an
explanatory comment.

https://github.com/thom311/libnl/pull/116

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-28 21:33:21 +01:00
Jef Oliver
54d5f1a1b4 lib/route: SRIOV Set Functionality
* This patch adds functionality to set attributes on an SRIOV
  VF object.
* This patch adds functionality to append attributes to the
  link change request sent to the kernel.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-24 13:27:39 +01:00
Jef Oliver
5b10c4598f lib/route: SRIOV Info Dump Functions
This patch adds functions to dump information and stats for each
SRIOV VF.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-24 13:27:39 +01:00
Jef Oliver
eab12c6260 lib/route: SRIOV Utility Functions
This patch adds utility functions for translating link state and
VLAN protocols for SRIOV VFs.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-24 13:27:39 +01:00
Jef Oliver
a59cab6d0b lib/route: SRIOV Clone Support
This patch adds support for cloning SRIOV VF specific data in the
link object.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-24 13:27:39 +01:00
Jef Oliver
5d6e43ebef lib/route: SRIOV Parse and Read support
* This patch adds support for parsing SRIOV VF specific
  information on a link.
  * Adds LINK_ATTR_VF_LIST to add to link->ce_mask.
  * Extends the rtnl_link object to include 'l_vf_list', a member
    to carry information for SRIOV VFs.
  * Adds rtnl_link_sriov, a private structure to fill link->l_vf_list.

* This patch adds support for reading parsed SRIOV VF specific
  informatino on a link.

* This patch adds support for freeing stored SRIOV VF specific
  information on a link.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-11-24 13:27:39 +01:00
Thomas Haller
8d04ebf554 lib/route: preserve old ABI for rtnl_link_get_pmtudisc()
Yes, rtnl_link_get_pmtudisc() was not in a public header.
But dropping it from ABI results in warnings of ABI checkers.

Just avoid that.
2016-11-05 18:08:05 +01:00
Jef Oliver
7a9b85c79c lib/route: Export correct ipgre functionality
* Rename rtnl_link_get_pmtudisc to rtnl_link_ipgre_get_pmtudisc
  in ipgre.c, making the function correctly match the exported
  functionality in ipgre.h. This fixes an error when trying to
  use the function, returning an incorrect type usage due to the
  link module already having a function of the same name.

* Export rtnl_link_is_[ipgre/ipgretap] allowing for usage per
  documentation.

Reported-by: Sharada Shiddibhavi <sharada.shiddibhavi@intel.com>
Signed-off-by: Jef Oliver <jef.oliver@intel.com>
2016-11-05 18:07:53 +01:00
Thomas Haller
23905cff48 vxlan: fix error code for missing attribute
Other VXLAN getters wrongly fail with -NLE_AGAIN.
That maybe should be fixed, but would be an API change.

New API should use the correct error code.
2016-11-05 17:35:01 +01:00
Thomas Haller
fb8cb3e917 vxlan: refactor setting/getting vxlan flags
As these properties are FLAG types in the netlink
API, we should also expose them as such in the
libnl API.

It is less code and require less code to support a new
flag.

The point is really to keep the API smaller instead of
wasting a getter and setter for each flag.
2016-11-05 17:33:43 +01:00
Thomas Haller
755b8cc008 vxlan: don't store vxlan flags as ce_mask
The ce_mask is there to indicate whether a certain attribute is
set or not. The VXLAN flags are different, because the flag is
either set or not. It cannot have the meaning of being missing.

Therefore, it should not be stored as a VXLAN_ATTR in ce_mask.
2016-11-05 17:27:13 +01:00
Thomas Haller
e21d71baad vxlan: restore previous VXLAN_ATTR flag values
The VXLAN_ATTR flags are internal and not public API.
Still, they are exposed as part of nl_object_diff().
There is no reason to change previous behavior, restore
the previous numeric values.
2016-11-05 17:05:40 +01:00
Thomas Haller
66b1dd64d0 vxlan: remove redundant enable/disable API from vxlan
The enable/disable API is redundant and increases the library
in binary size and documentation. There should be one sensible way
to do something, not several.

Yes, there is prior act to that like rtnl_link_vxlan_disable_proxy().
That doesn't mean it should be repeated.
2016-11-05 17:05:21 +01:00
Brandon Carpenter
d533736e22 vxlan: add support for additional VXLAN attributes.
Includes all VXLAN attributes as of Linux kernel 4.7.5. In particular it
adds the following attributes:

    * IFLA_VXLAN_PORT,
    * IFLA_VXLAN_UDP_CSUM,
    * IFLA_VXLAN_UDP_ZERO_CSUM6_TX,
    * IFLA_VXLAN_UDP_ZERO_CSUM6_RX,
    * IFLA_VXLAN_REMCSUM_TX,
    * IFLA_VXLAN_REMCSUM_RX,
    * IFLA_VXLAN_GBP,
    * IFLA_VXLAN_REMCSUM_NOPARTIAL,
    * IFLA_VXLAN_COLLECT_METADATA,
    * IFLA_VXLAN_LABEL,
    * IFLA_VXLAN_GPE

https://github.com/thom311/libnl/pull/110
2016-10-30 12:26:16 +01:00
Thomas Haller
0ec5b11ec3 macvlan: adjust types and merge MACVLAN_HAS_MACCOUNT and MACVLAN_HAS_MACDATA
mvi_maccount only makes sense together with the data. They should be
treated as one setting, and both should be consistent.
That means, if there are no addresses, mvi_maccount should always be set to
zero. This is regardless of whether the mvi_mask indicates that MACVLAN_HAS_MACADDR
is set. Similarly, if mvi_maccount is larger then zero, the mvi_macaddr
must point to some valid addresses.
The only exception is, when mvi_maccount is zero, mvi_macaddr may be
NULL or point to some data of zero allocated bytes.

Also, ensure that uint32_t is used for all the types that compare with
mvi_maccount.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-09-27 10:46:34 +02:00
Michael Braun
4b28f70d2b macvlan: add support for "source" mode
This adds libnl support for new "source" mode.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
2016-09-26 22:42:21 +02:00
Thomas Haller
f55cd5d75f bridge: change return values for rtnl_link_bridge_get_hwmode()
Unfortunately, libnl3 is rather inconsistent about the getters.
- some return the value directly, and don't have a dedicated
  error return value.
- some don't check whether the attribute was set and just
  return the default value
- some fail with -NLE_INVAL or -NLE_NOATTR if the value is
  unset.

I think the best pattern is to fail if the attribue is unset.
However, the return value should be negative to indicate an error,
while 0 should mean success.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-09-24 14:43:01 +02:00
Thomas Haller
d066ae5b6e trivial: whitespace
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-09-24 14:37:01 +02:00
Jef Oliver
1a4031d6db lib/route: Support IFLA_BRIDGE_MODE
This patch adds support for hardware assisted bridge modes stored
in IFLA_AF_SPEC[IFLA_BRIDGE_MODE].

This patch adds rtnl_link_[g/s]et_hwmode() functions, allowing
for getting and setting the hardware mode for a bridged link.

This patch adds the convenience functions for translating between
integer and string names for hardware modes.

This patch adds rtnl_link_bridge_set_self(), a function that
stores flags in IFLA_AF_SPEC[IFLA_BRIDGE_FLAGS], an attribute
that tells the kernel whether it should apply settings to the
virtual bridge device or the hardware device itself. This requires
hardware that supports the hardware flags.

This patch adds bridge_fill_af(), a function to fill IFLA_AF_SPEC
with AF_BRIDGE specific information.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-09-24 13:51:29 +02:00
Jef Oliver
ab17f9803d lib/route: Allow override of IFLA_AF_SPEC nesting
This patch adds the ability to override nesting into an AF specific
attribute. An example of this is the bridge module.

Regular Nesting:
[IFLA_AF_SPEC]
    [AF_INET]
        [AF_INET_ATTRS]

Bridge Nesting:
[IFLA_AF_SPEC]
    [AF_BRIDGE_ATTRS]

This patch adds ao_fill_af_no_nest to struct rtnl_link_af_ops.
When set to non-zero, this will override the nested AF attribute
and allow nesting of attributes directly into IFLA_AF_SPEC.

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-09-24 13:51:29 +02:00
Jef Oliver
9be1849eab lib/route: Extend Bridge Flags
This patch adds support for the following bridge port flags:

IFLA_BRPORT_UNICAST_FLOOD
IFLA_BRPORT_LEARNING
IFLA_BRPORT_LEARNING_SYNC

Signed-off-by: Jef Oliver <jef.oliver@intel.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2016-09-24 13:51:29 +02:00