Commit graph

54 commits

Author SHA1 Message Date
Tom Gundersen 9e7e440835 networkd: add support for source routing 2014-12-04 16:02:05 +01:00
Lennart Poettering a98433c05c rtnl: make checks for default routes more strict
Also check that the source netmask is 0, not only the destination
netmask.
2014-12-03 22:23:21 +01:00
Lennart Poettering e9140aff75 nss-myhostname: always resolve the host name "gateway" to the local default gateway
This is useful inside of containers or local networks to intrdouce a
stable name of the default gateway host (in case of containers usually
the host, in case of LANs usually local router).
2014-12-03 21:48:45 +01:00
Tom Gundersen 20dff6c4ff sd-rtnl: add sd_rtnl_message_{new_neigh,neigh_get_{family,ifindex}} 2014-12-02 10:19:53 +01:00
Tom Gundersen e559b38493 sd-rtnl: add typesystem for RTM_*NEIGH 2014-12-02 10:19:52 +01:00
Tom Gundersen dae4de9d42 sd-rtnl: add sd_rtnl_message_route_get_family 2014-12-02 00:58:17 +01:00
Alin Rauta be660c371b networkd: fix kernel rtnl receive buffer overrun error
We got the following error when running systemd on a device  with many ports:

"rtnl: kernel receive buffer overrun
Event source 'rtnl-receive-message' returned error, disabling: No buffer space
available"

I think the kernel socket receive buffer queue should be increased. The default
value is taken from:
"/proc/sys/net/core/rmem_default", but we can overwrite it using SO_RCVBUF
socket option.

This is already done in networkd for other sockets.
For example, the bus socket (sd-bus/bus-socket.c) has a receive queue of 8MB.
In our case, the default is 208KB.

Increasing the buffer receive queue for manager socket to 512KB should be enough
to get rid of the above error.

[tomegun: bump the limit even higher to 8M]
2014-11-27 18:59:47 +01:00
Susant Sahani 64c8407133 sd-rtnl: add support to set packet family type
This patch adds functionality to set family type
in the rtnl message for example PF_BRIDGE.
2014-10-29 10:59:46 +01:00
Lennart Poettering ee8c456895 networkd: add minimal client tool "networkd" to query network status
In the long run this should become a full fledged client to networkd
(but not before networkd learns bus support). For now, just pull
interesting data out of networkd, udev, and rtnl and present it to the
user, in a simple but useful output.
2014-08-12 01:54:40 +02:00
Dan Williams 28cc555d85 networkd: set route protocol
All routes added by networkd are currently set RTPROT_BOOT, which according
to the kernel means "Route installed during boot" (rtnetlink.h).  But this
is not always the case as networkd changes routing after boot too.  Since
the kernel gives more detailed protocols, use them.

With this patch, user-configured static routes now use RTPROT_STATIC (which
they are) and DHCP routes use RTPROT_DHCP.  There is no define for IPv4LL
yet, so those are installed as RTPROT_STATIC (though perhaps RTPROT_RA is
better?).

[tomegun: fixup
src/network/networkd-link.c:972:33: error: too few arguments to function 'route_new_dynamic']
2014-07-23 09:19:32 +02:00
Lennart Poettering 0dd25fb9f0 change type for address family to "int"
Let's settle on a single type for all address family values, even if
UNIX is very inconsitent on the precise type otherwise. Given that
socket() is the primary entrypoint for the sockets API, and that uses
"int", and "int" is relatively simple and generic, we settle on "int"
for this.
2014-07-18 16:10:51 +02:00
Lennart Poettering ca4e095ab9 sd-rtnl: make string returned by sd_rtnl_message_read_string() const 2014-07-18 12:38:32 +02:00
Tom Gundersen 897e184c7d rtnl: change from bitmask to enum for rtnl groups
The bitmask is deprecated in the kernel, so move to the new interface. At the moment
this does not make a difference for us, but it avoids having to change the API in the future.
2014-05-10 20:56:37 +02:00
Tom Gundersen f4e884dd1c sd-rtnl: message - add support for getting prefixlen from address messages 2014-05-10 20:56:37 +02:00
Tom Gundersen 6e20c8f8fa sd-rtnl: message - expose DUMP flag in the api 2014-04-19 16:47:52 +02:00
Tom Gundersen 1403f45ab6 sd-rtnl: multi-part message - store as linked-list rather than independent messages
This means the API can stay the same as for single-part messages by simply passing the head message around. Unrefing
the head of the linked list unrefs the whole list.
2014-04-14 17:53:21 +02:00
Tom Gundersen e00d77ddd5 sd-rtnl: message_addr - expose a few more getters 2014-04-14 17:53:01 +02:00
Umut Tezduyar Lindskog aba496a58a networkd: smooth transition from ipv4ll to dhcp address
Currently when both ipv4ll and dhcp are enabled, ipv4ll
address (if one has been claimed) is removed when dhcp
address is aquired. This is not the best thing to do
since there might be clients unaware of the removal
trying to communicate.

This patch provides a smooth transition between ipv4ll
and dhcp. If ipv4ll address was claimed [1] before dhcp,
address is marked as deprecated. Deprecated address is still
a valid address and packets can be received on it but address
cannot be selected as a source address. If dhcp lease cannot
be extended, then ipv4ll address is marked as valid again.

[1] If there is no collision, claiming IPv4LL takes between 4 to
7 seconds.
2014-04-03 16:00:25 +02:00
Tom Gundersen d8e538ecd9 sd-rtnl: rework rtnl type system
Use a static table with all the typing information, rather than repeated
switch statements. This should make it a lot simpler to add new types.

We need to keep all the type info to be able to create containers
without exposing their implementation details to the users of the library.

As a freebee we verify the types of appended/read attributes.

The API is extended to nicely deal with unions of container types.
2014-03-28 19:11:59 +01:00
Tom Gundersen 3dd215e056 sd-rtnl: add sd_rtnl_message_enter_container()
Extend rta_offset_tb into a stack of offset tables, one for each parent of the
current container, and make sd_rtnl_message_{enter,exit}_container() pop/push
to this stack.

Also make sd_rtnl_message_rewind() parse the top-level container, and use this
when reading a message from the socket.

This changes the API by dropping the now redundant sd_rtnl_message_read()
method.
2014-03-24 16:59:30 +01:00
Tom Gundersen 1f0db3ed88 sd-rtnl: never treat broadcasts as replies
Otherwise the sequence number of a broadcast may match the sequence number of a
pending unicast message and cause confusion.
2014-03-16 13:05:04 +01:00
Susant Sahani 4e9e7f1836 sd-rtnl: introduce read ether and ip address functions
This patch introduces reading ethernet address and IPV4/IPv6
as well which is based on table based look up.

[tomegun: rename read_ether() to read_ether_addr() to match the append function.]
2014-03-07 17:39:04 +01:00
Susant Sahani 44caa5e7df sd-rtnl:introduce table-based lookup and typesafe read() functions
This patch introduces new netlink attribute parsing logic
which is table based lookup and sd_rtnl_message_read_*
methods for reading attributes. By doing this user does not
have to loop for the attribute values . Only providing the
attribute type it gets the attribute values which is optimized
and sd_rtnl_message_read_* methods are simplified.
2014-03-06 19:30:09 +01:00
Umut Tezduyar Lindskog 5c1d3fc93d sd-network: IPv4 link-local support [v2]
Implements IPv4LL with respect to RFC 3927
(http://tools.ietf.org/rfc/rfc3927.txt) and integrates it
with networkd. Majority of the IPv4LL state machine is
taken from avahi (http://avahi.org/) project's autoip.

IPv4LL can be enabled by IPv4LL=yes under [Network]
section of .network file.

IPv4LL works independent of DHCP but if DHCP lease is
aquired, then LL address will be dropped.

[tomegun: removed a trailing newline and a compiler warning]
2014-03-03 23:24:34 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Tom Gundersen 4fb7242cbb sd-rtnl-message: store reference to the bus in the message
This mimics the sd-bus api, as we may need it in the future.
2014-02-18 11:21:22 +01:00
Tom Gundersen 818dc5e72a sd-rtnl: always include linux/rtnetlink.h 2014-02-15 12:14:45 +01:00
Tom Gundersen ee3a6a51e5 sd-rtnl: message_open_container - don't take a 'size' argument
We can always know the size based on the type, so let's do this inside the library.
2014-02-15 12:14:45 +01:00
Lennart Poettering 31a4e15384 rtnl: support adding VETH_INFO_PEER containers into rtnl messages 2014-02-13 18:47:53 +01:00
Lennart Poettering d595c5cc9e rtnl: rename constructors from the form sd_rtnl_xxx_yyy_new() to sd_rtnl_xxx_new_yyy()
So far we followed the rule to always indicate the "flavour" of
constructors after the "_new_" or "_open_" in the function name, so
let's keep things in sync here for rtnl and do the same.
2014-02-13 13:53:25 +01:00
Susant Sahani 7b1796403a Added attribute support for sd-rtnl
Added sd_rtnl_message_append_u8 and
  few attribute support in sd_rtnl_message_append_u32
       IFLA_GROUP, IFLA_TXQLEN, IFLA_NUM_TX_QUEUES, IFLA_NUM_RX_QUEUES
2014-02-05 00:07:29 +01:00
Tom Gundersen e5c4350b0d sd-rtnl: add support for reading containers
Also insist on messages being sealed before reading them. In other
words we don't allow interleaving of reading and appending to messages.
2014-01-24 22:20:34 +01:00
Tom Gundersen 5a72317435 sd-rtnl: simplify sd_rtnl_message_addr_new()
Split out into sd_rtnl_message_addr_set_{prefixlen,flags,scope}().
2014-01-22 18:01:45 +01:00
Tom Gundersen 01b36069cc sd-rtnl: add sd_rtnl_message_append_u16() 2014-01-22 17:56:49 +01:00
Tom Gundersen 5d4795f372 sd-rtnl: link - allow setting the change mask 2014-01-22 17:56:49 +01:00
Tom Gundersen 0a0dc69b65 rtnl: replace message_append by typesafe versions 2013-12-16 17:28:18 +01:00
Tom Gundersen 0fc7531b40 rtnl: support interleaved reading and writing, and rewind 2013-12-16 17:28:18 +01:00
Tom Gundersen 1f01fb4f29 rtnl: simplify route_new()
Drop most of the arguments and instead introduce set_dst_prefixlen().
2013-12-16 17:28:18 +01:00
Tom Gundersen fc25d7f805 rtnl: simplify link_new()
Drop most of the arguments and instead introduce link_set_{flags,type}.
2013-12-16 17:28:18 +01:00
Tom Gundersen 50b3c42f97 rtnl: add link_get_flags 2013-12-04 14:15:13 +01:00
Tom Gundersen 8cec01b9e9 rtnl: add callback support
sd_rtnl_add_match allows you to add a callback function for when given types of
messages are received.
2013-12-04 14:15:13 +01:00
Tom Gundersen 33125ac50b rtnl: add preliminary support for containers
For now, we only support one container type IFLA_LINKINFO, and we
still lack support for parsing the containers again.
2013-11-26 01:32:25 +01:00
Tom Gundersen b4f2a5b197 rtnl: add event loop integration 2013-11-14 23:22:58 +01:00
Tom Gundersen e16bcf986e rtnl: add call_async and call_async_cancel
They work in the same way as the sd-bus equivalents.
2013-11-14 14:32:48 +01:00
Tom Gundersen 4555ec72d6 rtnl: start adding support for asynchronous messaging
Similarly to sd-bus, add:

sd_rtnl_wait
sd_rtnl_process
sd_rtnl_send

and adapt sd_rtnl_call accordingly.
2013-11-13 19:52:17 +01:00
Tom Gundersen fe4824e065 rtnl: rename rtnl_bus_send_with_reply_and_block() to rtnl_bus_call()
Follow the equivalent rename in sd-bus to stay as similar as possible.
2013-11-13 19:48:44 +01:00
Lennart Poettering 0095c45415 api: replace manual C++ guards by macros 2013-11-07 16:53:26 +01:00
Lennart Poettering 6695ed7a84 api: add C++ guards 2013-11-07 03:47:42 +01:00
Lennart Poettering 0a0a68282c rtnl: headers in src/systemd/ may not use #pragma once 2013-11-07 03:40:43 +01:00
Lennart Poettering a33dece5f8 rtnl: headers in src/systemd/ may not include internal headers
Hence including "util.h" from sd-rtnl.h is not OK. Let's minimize our
headers we pull in a bit.
2013-11-07 03:39:32 +01:00