Commit graph

569 commits

Author SHA1 Message Date
Thomas Haller
b70174668b route: fix return value of nl_rtgen_request()
According to documentation, nl_rtgen_request() returns 0 on success,
but before it returned the number of bytes sent.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-31 14:46:13 +01:00
Thomas Haller
b203c89d86 addr: add address flag IFA_F_NOPREFIXROUTE
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-16 11:09:32 +01:00
Cong Wang
aa8877d5c1 act: remove rtnl_act_alloc_cache()
It is complicated to cache tc actions, they are different
from tc qdisc's and filters by design. So, it is simple
if we just don't cache them.

This patch only removes the tc action cache allocation API.
We still need to bypass the libnl cache layer from scratch,
but that would not break ABI any more, therefore we can do
it later.

Cc: Thomas Graf <tgraf@suug.ch>
Cc: Thomas Haller <thaller@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-15 14:16:46 +01:00
HongweiBi
8dabf9fb1a bridge: add rtnl_link_add_bridge() function
Signed-off-by: HongweiBi <hwbi2008@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-14 14:37:58 +01:00
Thomas Haller
dcc0baac02 addr: add address flag IFA_F_MANAGETEMPADDR
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-03 13:38:08 +01:00
Jiri Pirko
42c4133600 add support for IFA_FLAGS nl attribute
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-03 13:37:56 +01:00
Thomas Haller
2cf635b06a route: add libnl name prefix to global variable link_policy
Public names should be prefixed with a libnl specific
prefix to avoid name collisions. Rename link_policy to
rtln_link_policy.

Related bugs:
  https://github.com/thom311/libnl/issues/52
  https://bugzilla.gnome.org/show_bug.cgi?id=720902
  https://bugs.gentoo.org/show_bug.cgi?id=494986
  https://bugs.gentoo.org/show_bug.cgi?id=494890

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-02 11:56:56 +01:00
Thomas Haller
02c9c2518f build: fix build failure when using different build dir (make distcheck)
`make distcheck` builds outside the source directory using
`../configure --srcdir=..`. This was broken because libnl.sym was
expected in the $(top_srcdir) instead of $(top_builddir).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-17 18:26:31 +02:00
Cong Wang
d7aca17701 u32: add rtnl_u32_get_key()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-17 18:14:10 +02:00
Cong Wang
ea0eec9d30 add an assertion in rtnl_tc_set_link()
So that we can catch the bug easily.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-11 09:08:23 +01:00
Cong Wang
438e3ff21f fix some typo in lib/route/act.c
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:40:11 +01:00
Cong Wang
efdde42fcc basic: add action removal API
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:38:09 +01:00
Cong Wang
507897a53e u32: add action removal API
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:36:14 +01:00
Cong Wang
ffbfe92d74 add rtnl_mirred_get* functions
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:33:34 +01:00
Cong Wang
017c971142 rename rtnl_mirred_set_index() to rtnl_mirred_set_ifindex()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:33:27 +01:00
Cong Wang
b5309e1ea4 fix a bug in rtnl_act_fill()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:33:17 +01:00
Cong Wang
aa1c5628fd add a parameter to rtnl_link_veth_add()
Usually the peer of a veth device is moved to a new netns
after creation, so add a pid parameter to rtnl_link_veth_add().

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:28:33 +01:00
Cong Wang
8b87ae5516 fix rtnl_link_info_parse() and rtnl_link_fill_info()
So that the veth peer could be parsed correctly.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-12-09 15:28:32 +01:00
Samuel Gauthier
b50a36bf34 The commit 6a8d90f5fe "attr: Allow attribute type 0" intended to
allow the parsing of {netlink,packet,unix}_diag, even if they are
using type 0 for valid attributes.

It lacked this part in nla_parse.

Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-29 09:41:28 +01:00
Thomas Graf
6a8d90f5fe attr: Allow attribute type 0
{netlink,packet,unix}_diag use attribute type 0 for valid
attributes. The value was reserved and usage was prohibited
by the protocol but we can't undo the breakge.

Make libnl accept attribute type 0 to allow parsing these
attributes.

Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-28 23:14:38 +01:00
Cong Wang
ae19ac0154 add fq_codel cli module
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-22 10:13:40 +01:00
Cong Wang
d969a19d9f add fq_codel qdisc
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-22 10:13:39 +01:00
Thomas Graf
04040110cd link: Fall back to global provisioned link cache if object is not a cache resident
... if that fails, print ifindices directly.

Reported-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-09 10:13:50 +01:00
Cong Wang
24e8b522e5 basic: add action support
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-09 01:17:01 +01:00
Cong Wang
6cdc32df83 add u32 action support
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-09 01:16:14 +01:00
Cong Wang
9073aaf67e add mirred tc action
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-09 01:15:31 +01:00
Cong Wang
d6cfd04799 add initial tc action support
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-09 01:12:45 +01:00
Cong Wang
4f075a4fd1 do not compile some address families when not available
This fixes the following error while compiling libnl3 on CentOS5:

addr.c:1027: error: 'AF_RDS' undeclared here (not in a function)
addr.c:1033: error: 'AF_CAN' undeclared here (not in a function)
addr.c:1034: error: 'AF_TIPC' undeclared here (not in a function)
addr.c:1036: error: 'AF_IUCV' undeclared here (not in a function)
addr.c:1037: error: 'AF_RXRPC' undeclared here (not in a function)
addr.c:1038: error: 'AF_ISDN' undeclared here (not in a function)
addr.c:1039: error: 'AF_PHONET' undeclared here (not in a function)
make[2]: *** [addr.lo] Error 1

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-09 01:07:19 +01:00
Olaf Hering
2d20d097e7 Remove extra memset from __nlmsg_alloc
A few lines above nm->nm_nlh is already allocated with calloc, the
allocated memory has at least sizeof(struct nlmsghdr).

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2013-11-08 17:15:16 +01:00
Cong Wang
678753ba84 factor out rtnl_link_info_parse()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-06 09:55:04 +01:00
Cong Wang
760bfabad8 add link netns support
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-06 09:55:03 +01:00
Cong Wang
4263106728 add veth link support
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-06 09:55:02 +01:00
Cong Wang
1f3511c1d1 factor out rtnl_link_fill_info()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-11-06 09:55:01 +01:00
Cong Wang
43e9438d9a add ingress qdisc
This patch adds ingress qdisc to libnl.

Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-31 00:28:04 +01:00
Thomas Haller
549010c52a rtnl-addr: set ifa_flags when creating/updating address
Set the address flags when creating/updating an address with
rtnl_addr_add/rtnl_addr_build_add_request. Before, the flags
were not passed on.

As of now, the flags except IFA_F_NODAD|IFA_F_HOMEADDRESS are ignored by
the kernel. Still pass them on without filtering.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-22 14:24:56 +02:00
Thomas Graf
d976e2e62b obj: Check for NULL pointer in nl_object_clone()
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-22 14:20:41 +02:00
Nicolas PLANEL
978bb85c7a python: add bridge flags API
Add flags set/get methods aim to change bridge flags :
 o hairpin_mode
 o bpdu_guard
 o root_block
 o fast_leave

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-22 14:20:41 +02:00
Nicolas PLANEL
fdd1ba220d route/link: fixup link->l_af_ops must be set for some kind of links
Lookup on IFLA_INFO_KIND information to setup the right link->l_af_ops callbacks
For example, if you setup a bridge this is avoid to trig IS_BRIDGE_LINK_ASSERT() on rtnl_link_bridge_get_flags() call.

    line=<optimized out>, function=<optimized out>) at assert.c:94
    0x7ffff5dc39a0 "rtnl_link_bridge_get_flags") at assert.c:103

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-22 14:20:41 +02:00
Olaf Hering
1daa48c48d nl: Fix comment typo on recvmsgs
Signed-off-by: Olaf Hering <olaf@aepfle.de>
2013-10-01 18:23:54 +02:00
Arend van Spriel
934626903c nl_cb: store nl_cb_type in struct nl_cb
The application could use the same handler for multiple
nl_cb_type events. This patch stores the nl_cb_type in
the nl_cb struct during the callback. This allows the
application to obtain that information using the new
nl_cb_active_type() function. This way the callback
signature remains as is so existing applications are
not affected.

Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:46:00 +02:00
Holger Eitzenberger
db08ef44af netfilter/ct: support optional CTA_ZONE attribute
Newer kernels support conntrack zones, which help to partition the
conntrack table into virtual conntrack tables.

This patch is for adding support for the optional attribute, adds
setters and getters, and adds support for the zone ID in the conntrack
dumper.

An example entry in NL_DUMP_LINE format looks like:

  tcp SYN_SENT 10.128.128.99:43354 <-> 10.128.129.20:22 zone 1

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:39:03 +02:00
Holger Eitzenberger
56d2bbe173 netfilter/ct: support optional CTA_TIMESTAMP attribute
Recent kernels support conntrack time stamping, which is a helpful
feature to determine the duration of a flow without building a flow
cache in your user space application, just to keep the 'start' time of
your flow.

Timestamps are recorded with nanosecond resolution once this feature
is enabled.

This patch adds optional support for the CTA_TIMESTAMP, then
modifies the dump routine to write that info in a format similar
to /proc/net/nf_conntrack.  This is an example output when using
NL_DUMP_LINE:

  udp 10.128.128.28:56836 <-> 10.128.129.255:8612 delta-time 30

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05 17:38:59 +02:00
chantra
8a4f16b5bf Call to_msg_fill_raw when defined to_msg_fill is NULL
netem qdisc uses to_msg_fill_raw to build netlink packet. So far, this
was not called from anywhere.

Example creating a netem qdisc before and after the change:

[root@testbox libnl]# NLCB=debug ./netem
-- Debug: Sent Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 48
    .type = 36 <route/qdisc::new>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376894544
    .port = 17877
  [PAYLOAD] 20 octets
    00 00 00 00 02 00 00 00 00 00 01 80 01 00 01 00 ................
    00 00 00 00                                     ....
  [ATTR 01] 6 octets
    6e 65 74 65 6d 00                               netem.
  [PADDING] 2 octets
    00 00                                           ..
---------------------------  END NETLINK MESSAGE ---------------------------
-- Debug: Received Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 68
    .type = 2 <ERROR>
    .flags = 0 <>
    .seq = 1376894544
    .port = 17877
  [ERRORMSG] 20 octets
    .error = -22 "Invalid argument"
  [ORIGINAL MESSAGE] 16 octets
    .nlmsg_len = 16
    .type = 36 <0x24>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376894544
    .port = 17877
---------------------------  END NETLINK MESSAGE ---------------------------
-- Error received: Invalid argument
-- Original message: type=0x24 length=48 flags=<REQUEST,ACK,ATOMIC>
sequence-nr=1376894544 pid=17877
RC -7
[root@testbox libnl]# NLCB=debug ./netem
-- Debug: Sent Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 76
    .type = 36 <route/qdisc::new>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376895147
    .port = 26541
  [PAYLOAD] 20 octets
    00 00 00 00 02 00 00 00 00 00 01 80 01 00 01 00 ................
    00 00 00 00                                     ....
  [ATTR 01] 6 octets
    6e 65 74 65 6d 00                               netem.
  [PADDING] 2 octets
    00 00                                           ..
  [ATTR 02] 24 octets
    00 00 00 00 a0 86 01 00 00 00 00 80 00 00 00 00 ................
    00 00 00 00 00 00 00 00                         ........
---------------------------  END NETLINK MESSAGE ---------------------------
-- Debug: Received Message:
--------------------------   BEGIN NETLINK MESSAGE ---------------------------
  [NETLINK HEADER] 16 octets
    .nlmsg_len = 36
    .type = 2 <ERROR>
    .flags = 0 <>
    .seq = 1376895147
    .port = 26541
  [ERRORMSG] 20 octets
    .error = 0 "Success"
  [ORIGINAL MESSAGE] 16 octets
    .nlmsg_len = 16
    .type = 36 <0x24>
    .flags = 1029 <REQUEST,ACK,ATOMIC>
    .seq = 1376895147
    .port = 26541
---------------------------  END NETLINK MESSAGE  ---------------------------
RC 0
[root@testbox libnl]# tc qdisc show
qdisc htb 1: dev eth0 root refcnt 2 r2q 10 default 0 direct_packets_stat 21115
qdisc netem 8001: dev eth0 parent 1:1 limit 100000 loss 50%
qdisc htb 1: dev eth1 root refcnt 2 r2q 10 default 0 direct_packets_stat 0

Signed-off-by: chantra <chantra@fb.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-08-26 10:11:12 +02:00
Jiri Pirko
6f37b439af fix double free caused by freeing link af_data in rtnl_link_set_family()
Introduced by commit 8026fe2e3a ("link:
Free and realloc af specific data upon rtnl_link_set_family()")

link->l_af_data[link->l_af_ops->ao_family] is freed here but not set to
zero. That leads to double free made by link_free_data->do_foreach_af.

Fix this by setting link->l_af_data[link->l_af_ops->ao_family] to zero
rigth after free.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-08-21 14:46:42 +02:00
Thomas Graf
0eb665c693 Enable linker versioning
Reported-by: Ian Stakenvicius
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-08-07 14:51:03 +02:00
Thomas Graf
8443c7e9f1 Merge pull request #44 from sassanosystems/idiag
Idiag
2013-08-04 23:10:42 -07:00
Jiri Pirko
57f1d9f03a link: add support for IFLA_PHYS_PORT_ID
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-08-05 08:08:55 +02:00
Yasunobu Chiba
162c906bf2 Add VXLAN support. 2013-08-04 15:43:54 +09:00
Joe Damato
2ef91dac26 More safely parse vegas info and mem info. 2013-07-25 17:59:56 -07:00
Joe Damato
b3fb89f445 Handle the case where nl_msec2str is passed 0 msecs 2013-07-19 02:06:27 -07:00