Commit Graph

81 Commits

Author SHA1 Message Date
Nicolas Dichtel
d182ee1307 ipnetns: allow to get and set netns ids
The kernel now provides ids for peer netns. This patch implements a new command
'set' to assign an id.
When netns are listed, if an id is assigned, it is now displayed.

Example:
 $ ip netns add foo
 $ ip netns set foo 1
 $ ip netns
 foo (id: 1)
 init_net

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2015-02-21 16:54:53 -08:00
Vadim Kochan
27b14f2e87 Add define for nlmsg_types with timestamp
Add #define for nlmsg_type = 15

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-01-13 17:34:47 -08:00
Jiri Pirko
decbb4378c libnetlink: add parse_rtattr_one_nested helper
Sometimes, it is more convenient to get only one specific nested attribute by
type. For example for IFLA_AF_SPEC where type is address family (AF_INET6).
So add this helper for this purpose.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2015-01-07 15:11:35 -08:00
Vadim Kochan
486ccd99a0 ss: Use rtnl_dump_filter for inet_show_netlink
Just another refactoring for ss to use rtnl API from lib

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-12-27 10:21:10 -08:00
vadimk
8a4025f6a4 ss: Use rtnl_dump_filter in handle_netlink_request
Replaced handling netlink messages by rtnl_dump_filter
from lib/libnetlink.c, also:

    - removed unused dump_fp arg;
    - added MAGIC_SEQ #define for 123456 seq id;
    - silently exit if ENOENT errno is caused for NETLINK_SOCK_DIAG proto
        in lib/libnetlink.c: rtnl_duml_filter_l(...) function. This fix
        was added in a3fd8e58c1 by Eric
        for misc/ss.c

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2014-12-20 12:17:02 -08:00
Stephen Hemminger
d2468da0a3 check return value of rtnl_send and related functions
Use warn_unused_result to enforce checking return value of rtnl_send,
and fix where the errors are.

Suggested by initial patch from Petr Písař <ppisar@redhat.com>
2013-12-20 08:24:44 -08:00
Vlad Yasevich
b1b7ce0f0d bridge: Add support for printing bridge port attributes
Output new nested bridge port attributes.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
2013-03-16 10:02:18 -07:00
Vlad Yasevich
9eff0e5cc4 bridge: Add vlan configuration support
Recent kernel patches added support for VLAN filtering on the bridge.
This functionality allows one to turn a basic bridge into a VLAN bridge,
where VLANs dicatate packet forwarding and header transformation.

To configure the VLANs on the bridge and its ports a new command is
added to the 'bridge' utility.

   # bridge vlan add dev eth0 vid 10 pvid untagged brdev
   # bridge vlan add
   # bridge vlan delete dev eth0 vid 10
   # bridge vlan show

This command supports the following flags:
   master - peform the operation on the software bridge device.  This is
	    the default behavior.
   self  -  perform the operation on the hardware associated with the port.
            This flag is required when the device is the bridge device and
	    the configuration is desired on the bridge device itself (not
	    one of the ports).
   pvid  -  Set the PVID (port vlan id) for a given port.  Any untagged
            frames arriving on the port will be assigned to this vlan.
   untagged - Sets the egress policy of for a given vlan.  Default port
            egress policy is tagged.  Set this flag if you wish traffic
            associated with this VLAN to exit the port untagged.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
2013-03-06 11:03:08 -08:00
Strake
5bd9dd49ae include needed files
Needed to build iproute2 with musl
2012-12-23 11:49:06 -08:00
Nicolas Dichtel
9d0efc1048 ip: add support of 'ip link type ip6tnl'
This patch allows to manage ip6 tunnels via the interface ip link.
The syntax for parameters is the same that 'ip -6 tunnel'.

It also allows to display tunnels parameters with 'ip -details link' or
'ip -details monitor link'.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2012-12-12 09:09:23 -08:00
Stephen Hemminger
7dd0371222 Fix rta_getattr_u32 wrapper and add getattr_u8 2012-03-15 17:47:51 -07:00
Stephen Hemminger
cfd2cbd15f Add cast to rta_getattr_str
Warning from C++
2012-02-06 09:35:27 -08:00
Jan Engelhardt
f5b830dc5d iproute2: avoid use of implicit declarations
gcc -DLIBDIR=\"/usr/lib64\" -D_GNU_SOURCE -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wstrict-prototypes -fPIC -DXT_LIB_DIR=\"/usr/lib64/xtables\" -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib64\" -fPIC   -c -o ipx_pton.o ipx_pton.c
In file included from ../include/utils.h:8:0,
                 from ipx_ntop.c:5:
../include/libnetlink.h: In function 'rta_getattr_u64':
../include/libnetlink.h:84:2: warning: implicit declaration of function 'memcpy'
../include/libnetlink.h:84:2: warning: incompatible implicit declaration of built-in function 'memcpy'
2012-01-03 13:48:04 -08:00
Stephen Hemminger
46c5d64d69 libnetlink: add attribute access inline functions
Based on idea in libmnl, add attribute access functions instead
of explicitly exposing casts. Also handle possible alignment issues
of u64.
2011-12-29 09:29:33 -08:00
Stephen Hemminger
cd70f3f522 libnetlink: remove unused junk callback
Both rtnl_talk and rtnl_dump had a callback for handling portions
of netlink message that do not match the correct pid or seq.
But this callback was never used by any part of iproute2 so remove
it.
2011-12-28 10:37:12 -08:00
Stephen Hemminger
2aa3dd29a7 libnetlink: add more attribute functions
New functions to handle u8, u16, u32, u64 and string attribute types.
Use common code for all attribute wrappers.
2011-12-23 10:43:54 -08:00
Stephen Hemminger
6cf8398f5f libnetlink: change rtnl_send() to take void *
Avoid having to cast buffer being sent.
2011-12-23 10:41:50 -08:00
Simon Horman
b49240ec7e flush secondary addresses before primary ones
Unless promote_secondaries has been active deleting the primary address of
an interface will automatically delete all the secondary addresses.

In the case where ip flush requests the primary then secondary addresses to
be removed - which is the order the addresses are returned by the kernel -
this will cause an error as by the time the request to remove a secondary
address is made it will be missing as it will have been deleted in the
course of deleting the primary address.

This approach to solving this problem orders requests for the
deletion of secondary addresses before primary ones providing
rtnl_dump_filter_l(), a version of rtnl_dump_filter() that
iterates over a list of filters. And by providing two specialised
filters print_addrinfo_secondary() and print_addrinfo_primary().

rtnl_dump_filter_l() first iterates over all addresses using
print_addrinfo_secondary(), which appends secondary addresses to the
request buffer.  Then again using print_addrinfo_primary() which appends
primary addresses.

This approach should work regardless of it promote_secondaries is
active or not. And regardless of if any primary of secondary addresses
are present or not.

Signed-off-by: Simon Horman <horms@verge.net.au>
2009-12-26 10:11:02 -08:00
Patrick McHardy
7f03191fda iproute uses too small of a receive buffer
It uses 1MB as receive buf limit by default (without
increasing /proc/sys/net/core/rmem_max it will be limited by less
however) and allows to specify the size manually using "-rcvbuf X"
(-r is already used, so you need to specify at least -rc).

Additionally rtnl_listen() continues on ENOBUFS after printing the
error message.
2009-11-10 09:14:33 -08:00
Stephen Hemminger
f31a37f79d fix problem caused by rtnl_send checks
Some usages of rtnl_send could cause errors (ie flush requests)
others do a listen afterwards.

Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
2008-01-31 21:38:58 -08:00
Patrick McHardy
2f90c9c0bb IPROUTE2: RTNETLINK nested attributes
This adds capability for iproute2 to send nested attributes to the
kernel, while maintaining backwards compatibility.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2007-08-22 10:04:20 -07:00
Stephen Hemminger
ae665a522b Remove trailing whitespace
Go through source files and remove all trailing whitespace

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:10:22 -08:00
Stephen Hemminger
ead2ba7008 Update to 2.6.19 headers
Headers extracted from early 2.6.20 development process

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 09:54:48 -08:00
5!tgraf
753fca4f54 parse_rtattr_nested macro to parse nested TLVs
(Logical change 1.129)
2005-01-18 22:11:58 +00:00
5!tgraf
a10ab08b00 addraw_l prototype
(Logical change 1.128)
2005-01-18 13:58:49 +00:00
5!tgraf
370d67ba56 Add NLMSG_TAIL macro pointing to the tail of a netlink message
(Logical change 1.127)
2005-01-18 01:24:18 +00:00
osdl.net!shemminger
50772dc51a Add ip rule flush capabilty and fix all the prototype changes
because of that code rewrites the nlmsghdr.

(Logical change 1.106)
2004-12-07 21:48:29 +00:00
osdl.net!shemminger
6dc9f01634 make all filtering handles take const args.
(Logical change 1.77)
2004-08-31 17:45:21 +00:00
net[shemminger]!shemminger
c7699875be Import patch ipxfrm-20040707_2.diff
(Logical change 1.53)
2004-07-07 17:05:56 +00:00
osdl.org!shemminger
aba5acdfdb (Logical change 1.3) 2004-04-15 20:56:59 +00:00
osdl.org!shemminger
86fdf0e47b Initial revision 2004-04-15 20:56:59 +00:00