dect
/
libnl
Archived
13
0
Fork 0
Commit Graph

359 Commits

Author SHA1 Message Date
Thomas Graf 21d52eabba Support for NLM_F_INTR
Check if a dump was interrupted and needs to be redone
2011-07-14 10:51:49 +02:00
Thomas Graf ca0fc75580 socket: Set SOCK_CLOEXEC if available
Reported by Марк Коренберг <socketpair@gmail.com>
2011-06-15 17:37:28 +02:00
Thomas Graf c881908ac7 neigh: include ndm flags while building message
Reported by jeff courington <jeff_courington@hotmail.com>
2011-06-15 16:23:35 +02:00
Thomas Graf 09210d9619 HTB: Add support for level and direct pkt stats, complete access functions
- Adds support for htb class level and direct packet
  statistics
- Complete all get/set access functions
- Complete error handling
- Documentation
2011-06-09 13:32:13 +02:00
Thomas Graf 053c93fa8a Update local copies of include/linux 2011-06-09 12:56:52 +02:00
Thomas Graf aba3689937 Provide documentation for rtnl_tc_data() and rtnl_tc_data_check() 2011-06-09 12:30:15 +02:00
Thomas Graf 58e0e1eda9 Add nl_rate2str() 2011-06-09 12:29:21 +02:00
Thomas Graf ed69b2a79b Add rtnl_tc_data_check()
Behaves like rtnl_tc_data() but verifies that the traffic control
object is of the expected type.
2011-06-09 12:28:04 +02:00
Thomas Graf 4cb1666fe1 Provide silent variation of nl_cache_require()
Use in addr and tc layer to avoid warnings being printed if no
cache is available.
2011-05-11 09:33:29 +02:00
Thomas Graf 023c662327 Use name "global" instead of "universe" for largest scope
This name is more widespread and easier to understand even though
it is less correct.
2011-05-04 17:47:09 +02:00
Thomas Graf d44c31da5f addr: store link object and provide rtnl_addr_get()
stores rtnl_link object in address if cache is availble. Provide access
via rtnl_addr_get_link() and rtnl_addr_set_link().

Add rtnl_addr_get() which searches a address cache for an address
matching ifindex and local address.
2011-05-03 11:48:14 +02:00
Romary Sonrier cb6a089d80 Adding rule with "From" option doesn't work
OK i found the bug, is is the patch !!

Can someone push it into the git tree ?
Regards,

Romary Sonrier

=========================
My analysis:

I guess that the pay load is *struct fib_rule_hdr*
struct fib_rule_hdr {
__u8 family;
__u8 dst_len;
__u8 src_len;
__u8 tos;

__u8 table;
__u8 res1; /* reserved */
__u8 res2; /* reserved */
__u8 action;

__u32 flags;
};

> [PAYLOAD] 12 octets
> 02 00 00 00 0a 00 00 01 00 00 00 00 ............
so

family = 02 , fine

table = 10, fine
but
src_len =0 !!!! should be 32
2011-05-03 11:40:21 +02:00
Thomas Graf daefa76959 Provide rtnl_tc_get_link() and fix link refcnt
Adds rtnl_tc_get_link() returning the link associated with a tc
object.

Don't clone link associated with tc object when cloning the tc
object, refer to same link instead and bump refcnt.

Fix refcnt leak when assigning link in msg parser.
2011-04-21 14:48:54 +02:00
Thomas Graf 83f14112e2 Fix clone() of AF specific link data
Passed the original link to ao_clone() instead of the new one.
2011-04-21 14:46:06 +02:00
Thomas Graf c18730ddf6 Set tc->tc_link if link cache is available
When parsing tc objects, lookup link in link cache if such a
cache is available.
2011-04-20 16:30:49 +02:00
Thomas Graf fac4885608 Improve readability of classid string representation
1: is more readable than 01:
2011-04-20 16:29:42 +02:00
Thomas Graf 4c6dd3a8bd Expose <netlink/route/link/inet.h> 2011-04-20 11:53:04 +02:00
Thomas Graf 36b04747c7 Support link info types with no payload 2011-04-19 09:57:35 +02:00
Thomas Graf 3d70697e4c Add support for ARPHRD_NONE 2011-04-19 09:57:14 +02:00
Thomas Graf 5a6610190a dummy interface support 2011-04-15 15:31:22 +02:00
Thomas Graf e81814a29f Support for rtnl_link_add()
API for adding virtual links
2011-04-15 15:30:46 +02:00
Thomas Graf 96bc6d6f66 Improve rtnl_link_change() behaviour
- avoid unncessary name change requests
    The kernel does not check if the specified IFNAME is different
    from the current name. It assumes that if IFNAME and ifindex
    are both specified, a name change is requested. Therefore avoid
    specyfing IFNAME if ifindex is provided and original and new
    name are identical.
- move link building to own function (to allow link add later on)
- error if immutable changes have been made
- better documentation
2011-04-13 16:42:34 +02:00
Thomas Graf b5918b5ce3 fix line removed by mistake
This line was removed by mistake in the last commit
2011-04-11 12:40:40 +02:00
Thomas Graf 48d543cfdf API to issue direct GET requests to the kernel
Provide nl_pickup() to pick up an answer from a netlink request and parse
it using the supplied parser.

Add rtnl_link_get_kernel() which sends an RTM_GETLINK to the kernel to
fetch a single link directly from the kernel. This can be faster than
dumping the whole table, especially if lots of links are configured.
2011-04-11 12:34:01 +02:00
Thomas Graf 41fb241b7b link: Provide rtnl_link_delete() to delete virtual links
Takes a link object and extracts ifindex and name to build a deletion request
message to delete virtual network links.
2011-04-10 11:02:47 +02:00
Thomas Graf 0893aafcec link: Make return and argument type match 2011-04-10 10:24:12 +02:00
Thomas Graf 23c27b4738 Provide nl_cache_set_arg{1,2}() to specify cache args
Added based on a RFE. This is required if allocation and
(re)filling is to be splitted.
2011-04-10 10:22:27 +02:00
Thomas Graf ef327ffd44 Provide nl_object_dump_buf() to easily dump to buffers 2011-04-10 10:22:01 +02:00
Thomas Graf 2dbe7d7cfc Initialize dump buffer in case caller missed it
(Set an end to all the bug reports of applications failing
to do so.)
2011-04-10 10:18:04 +02:00
Thomas Graf 7c620500bb trafic class/classifer API improvements and documentation
- removed dead functions in header files
- deprecated rtnl_class_foreach_*() functions due to their missing
  handling possibility of OOM situations
- improved API documentation
2011-03-29 12:41:59 +02:00
Thomas Graf 747b892c91 Qdisc API improvements and documentation
Deprecated the functions rtnl_qdisc_change() and
rtnl_qdisc_build_change_request() for their lack of being able to
specify flags. The new functions rtnl_qdisc_update() and
rtnl_qdisc_build_update_request() may be used instead. The old
functions are still available though. However, rtnl_qdisc_update()
no longer implies NLM_F_REPLACE, it has to specified implicitely
to allow updating a qdisc without risking to replace another qdisc.

Included detailed documentation of qdisc addition/update/deletion.

Introduced APPBUG() macro to let application developer know of
API abuse.
2011-03-25 18:13:19 +01:00
Thomas Graf 23845e942c Add nl_send_sync()
Function which sends message using nl_send_auto(), frees the message and
waits for ACK/error message (if auto-ack is not disabled).
2011-03-25 18:11:52 +01:00
Nicolas Sitbon 7e9d5f69e5 correctly handle the object not found case
Removing non existent route (both ipv4 and ipv6) using
rtnl_route_delete return NLE_FAILURE generic error code. After
investigation, it seems the linux kernel return -ESRCH in that case
(see http://lxr.linux.no/linux+v2.6.38/net/ipv6/route.c#L1367). Same
behaviour apply for removing non existent address. The function
nl_syserr2nlerr (lib/error.c) which is responsible for translating
from kernel error to libnl error doesn't handle ESRCH.
2011-03-25 16:51:31 +01:00
Thomas Graf e4b507e290 Deprecate rtnl_qdisc_foreach_child() and rtnl_qdisc_foreach_cls()
Their usage is not completely safe, it is not possible to handle
the out of memory situation of the allocate filter. It is very
unlikely for this to cause any problem though.

The functions are still accessible but gcc will warn about their
deprecation.
2011-03-24 22:50:11 +01:00
Thomas Graf f523f297f7 Allow NLSYSCONFDIR environment variable to overwrite built-in sysconfdir 2011-03-24 21:14:52 +01:00
Thomas Graf 8d5493418a Cleanup <netlink/route/qdisc.h>
- remove dead prototypes
- reformat
2011-03-24 20:57:43 +01:00
Thomas Graf a62bfdb8e0 Check if all mandatory attributes are present in rtnl_tc_msg_build()
TCA_ATTR_IFINDEX | TCA_ATTR_PARENT | TCA_ATTR_KIND
2011-03-24 17:00:38 +01:00
Thomas Graf 93b6c114a8 Add NLE_NODEV error 2011-03-24 16:56:10 +01:00
Thomas Graf 14fa557ba9 Set default MTU to 1500 2011-03-24 12:59:57 +01:00
Thierry Reding 9f1abddb1a Fix "make distcheck".
This commit adds some missing files (some header files, the files below
/etc and the bison/flex files) to the distribution tarball to ensure
that libnl can be built from the tarballs created using "make dist".

It also adds some incantations to properly generate the flex and bison
output since the generated output is no longer shipped in the tarball.
2011-03-23 16:00:44 +01:00
Thierry Reding 913579b460 Fix out-of-tree build.
This patch fixes out-of-tree build, that is, when building with
$builddir != $srcdir. In such a case, some generated header files are
not found because they live in a different tree and can be fixed by
adding the directories to the compiler's include search path.
2011-03-23 15:51:56 +01:00
Thomas Graf a0fe7a1c9a Omit empty nested attributes
Check for empty nested attributes in nla_nest_end() and omit the
attribute alltogether if is is the case.
2011-03-23 13:39:18 +01:00
Daniel Walter f0603a467b add missing checks for ROUTE_ATTR_MULTIPATH
attached patch adds missing checks for ROUTE_ATTR_MULTIPATH
when dealing with multipath routing.

Affected functions

rtnl_route_remove_nexthop
rtnl_route_get_nexthops
rtnl_route_get_nnexthops
2011-03-22 13:11:09 +01:00
Thomas Graf c1073d6172 Documentation updates
Mostly killing doxygen warnings, some doc updates to caching
2011-03-22 00:40:26 +01:00
Thomas Graf 722a227795 fix module parent references 2011-03-21 16:54:37 +01:00
Thomas Graf 45941f9d5f rename sch -> qdisc 2011-03-21 16:47:42 +01:00
Thomas Graf 8eb5b5532e Unified TC API
Finally got rid of all the qdisc/class/cls code duplication in
the tc module API. The API takes care of allocation/freeing the
tc object specific data.

I hope I got it right this time.
2011-03-21 15:51:52 +01:00
Thomas Graf 5dc897d5de provide function to retrieve htb rate 2011-03-17 17:31:08 +01:00
Thomas Graf 552c85cab7 Hold reference to obj while calling callback of cache iterator 2011-03-17 17:30:32 +01:00
Thomas Graf 33e94038c4 Print debugging info while iterating a cache based on a filter 2011-03-17 16:40:39 +01:00
Thomas Graf 2c75886060 Fix off-by-one when reading IFLA_INET6_CONF and IFLA_INET6_STATS 2011-03-17 16:11:10 +01:00
Thomas Graf 5a9f50b8e9 __nlmsg_alloc(): Guarantee minimal message size of at least the header 2011-03-17 16:03:11 +01:00
Miguel Di Ciurcio Filho 59c3474b3d Add missing argument in rtnl_link_change example
Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
2011-03-16 13:49:08 +01:00
Reuben Hawkins b5c474e533 allowing silent rules in build 2011-03-16 13:21:50 +01:00
Thomas Graf 4b0126b8e6 prefix ipv6 link statistics identifiers with IP6 2011-03-16 12:55:19 +01:00
Thomas Graf 7105aea116 addr: hide nl_addr_destroy()
everyone should use nl_addr_put()
2010-11-26 16:32:10 +01:00
Thomas Graf 4fb528bbaf nl_recv(): Zero out sockaddr in case the caller forgot 2010-11-22 14:19:40 +01:00
Thomas Graf 9fbdf6c92a nl_recv(): Make passing creds pointer optional 2010-11-22 14:18:59 +01:00
Thomas Graf e52a09c507 nl: rename nlmsg_msg_size() to nlmsg_size(), nlmsg_len() -> nlmsg_datalen()
The old symbols are left around for compatibility.
2010-11-22 13:13:04 +01:00
Thomas Graf 6545206187 Documentation updates
- moved documentation from lib/doc.c to doc/src/
 - splitted pages into separate files
 - worked over core sections, explaining the receiving and sending
   behaviour in much more details including the the available
   mechanisms to customize the behaviour
 - updated the html stylesheet file for increased readability, probably
   needs some doxygen patching to achieve what I am looking for.
 - enabled call graphs, not expanded by default
2010-11-19 02:25:37 +01:00
Thomas Graf 5a08c8ff4c Inherit return code of NL_CB_MSG_OUT in nl_sendmsg()
If NL_CB_MSG_OUT() returns anything != NL_OK, return that value
to let any caller of nl_sendmsg() know that the message has not
been sent.
2010-11-18 14:16:33 +01:00
Thomas Graf 8a365dbd49 rename nl_send_auto_complete() -> nl_send_auto(), nl_auto_complete -> nl_complete_msg()
Old symbols left to maintain backwards compatibility
2010-11-18 14:13:49 +01:00
Thomas Graf 063a2ebf53 only perform automatic sequence checking if auto-ack mode is enabled 2010-11-18 12:51:20 +01:00
Thomas Graf 09daef3d83 Don't build doc.c, there is no real code in it 2010-11-18 12:47:40 +01:00
Thomas Graf c32c3f3664 socket: constify interface 2010-11-18 12:47:16 +01:00
Thomas Graf cf5577d280 constify struct trans_tbl 2010-11-17 16:09:08 +01:00
Thomas Graf 98ffedec04 link/inet6: pretty printing 2010-11-17 15:14:08 +01:00
Thomas Graf d8eeb0a26f New function nl_size2str() 2010-11-17 15:13:33 +01:00
Thomas Graf 10424b20c1 Rename nl_get_hz() to nl_get_user_hz() to indicate it's not the in-kernel HZ value 2010-11-17 11:55:42 +01:00
Thomas Graf 3a9562001c sfq: perturb period is in seconds, not jiffies 2010-11-17 11:55:03 +01:00
Thomas Graf 4d28cc51bc link/inet: pretty printing, make output more readable 2010-11-17 00:06:34 +01:00
Thomas Graf 01bc3c58c2 link/inet: documentation: add examples 2010-11-16 15:07:27 +01:00
Thomas Graf ee57cc716f link: define RTM_SETLINK to allow pretty printing 2010-11-16 13:54:54 +01:00
Thomas Graf 2575d03135 link: Add missing IFLA_AF_SPEC container attribute 2010-11-16 13:54:15 +01:00
Thomas Graf e2099719a5 link/inet: Fix array access 2010-11-16 13:47:41 +01:00
Thomas Graf b6592cb5de link: Fix typo, use rtnl_link_af_alloc() to make sure data buffer is allocated 2010-11-16 13:46:49 +01:00
Thomas Graf 53015f8381 link: AF_INET link module
Note: The code for this is not upstream yet.

Extends the link api to allow address family modules to fill a link
message and implements a AF_INET address family link module which
uses the new interface.
2010-11-16 12:41:43 +01:00
Thomas Graf 2e3ca4db0c link: Support for IFLA_AF_SPEC
This feature isn't upstream yet. It's required to test a patch in
my local tree.

Makes the link parser understand IFLA_AF_SPEC and call the address
family specific parser.
2010-11-13 01:38:13 +01:00
Thomas Graf a4efc65c3a link: Add support for IPv6 specific link data
- parses IFLA_PROTINFO
 - dumps flags, cacheinfo, devconf and all statistics
2010-11-11 23:15:28 +01:00
Thomas Graf e69efadc46 Add support for per interface ICMPv6 statistics 2010-11-11 23:14:57 +01:00
Thomas Graf 7ff4deeb56 Extend rtnl_link_alloc_cache() to support address families
Adds a family argument which allows to request link dumps for a certain
address family. This allows to f.e. dump ipv6 specific statistics and data.

nl-link-list --family inet6
2010-11-11 22:26:11 +01:00
Thomas Graf 2847cf081b Make nl_str2af return a negative value if parsing fails 2010-11-11 22:25:32 +01:00
Thomas Graf 12b82e4f6f link/api: Improve API documentation. 2010-11-11 16:38:53 +01:00
Thomas Graf 67aeb7474f link/api: Convert link info ops to use nl_list_head
rtnl_link_info_ops_lookup() now returns a pointer with refcnt increment,
you must return it using rtnl_link_info_ops_put()
2010-11-11 16:18:53 +01:00
Thomas Graf 800013b787 link: Support for AF_BRIDGE address family
Supports parsing of IFLA_PROTINFO returned when dumping with PF_BRIDGE
2010-11-11 16:02:48 +01:00
Thomas Graf 280d457c22 link/api: Check for null pointer in rtnl_link_af_ops_put() 2010-11-11 16:02:02 +01:00
Thomas Graf 3fa6a6b410 link: API for address family specific link data
Introduces a new API to handle address familiy specific link data such as
IFLA_PROTINFO. It provides entry hooks for parsing IFLA_PROTINFO attributes
and allows to include the parsed data when a link object is dumped.
2010-11-11 15:50:49 +01:00
Thomas Graf fd857eeb9f link: Support IFLA_NUM_VF attribute
- parses attribute if available
- provides API to access value
    rtnl_link_get_num_vf(link, num_vf)
2010-11-11 14:11:32 +01:00
Thomas Graf 8970c5cde6 link: Support IFLA_IFALIAS attribute
- parse IFLA_IFALIAS if available
- provides API to access/change ifalias
     rtnl_link_get_ifalias(link)
     rtnl_link_set_ifalias(link, alias)
- extends nl-link-set to test functionality
2010-11-11 13:57:10 +01:00
Thomas GraF 59880cb01e pktloc: support to specify a shift operator for packet locations
no users yet though.
2010-11-04 20:01:36 +01:00
Thomas GraF d283c8e889 Correctly state the process of sending a netlink message. A message
passes through nl_send_iovec() before hitting nl_sendmsg()
2010-11-04 19:35:57 +01:00
Thomas Graf d95a4193f3 ematch/meta: id definitions 2010-11-03 01:09:28 +01:00
Thomas Graf 4e48d90e71 Correctly parse and generate classids
Make sure to parse strings starting with a hex represention letter
but not representing a valid number as tc names.

Fix typo while generating classid.
2010-11-01 13:17:19 +01:00
Thomas Graf 4267d8f336 classid auto generation if provided tc name does not exist
Manually editing etc/libnl/classid before adding tc objects is a pain.
This patch adds code to attempt auto generating a unique tc id which
will then be assigned to the provided name and added to the classid
file.

This will make the following commands work with prior definitions of
the names "top" and "test"
	sudo sbin/nl-qdisc-add --dev eth0 --parent root --id top htb
	sudo sbin/nl-class-add --dev eth0 --parent top --id test htb --rate 100mbit

It will generate the following ids automatically:
4001:			top
4001:1			test
2010-11-01 08:17:40 +01:00
Thomas Graf 7903d6ab4b Support for meta match
Syntax:
	meta(pktlen > 768)
2010-10-31 23:13:01 +01:00
Thomas Graf c7a673787b text ematch support 2010-10-29 21:10:02 +02:00
Thomas Graf 93f992eac5 attr: Add padding if nested data does not end at an alignment boundry
This could happen if a user put an unaligned amount of data inside
an attribute with nlmsg_append().
2010-10-29 18:40:48 +02:00
Thomas Graf cc22992d0c Improved debugging messages while constructing messages/attributes 2010-10-29 18:34:27 +02:00
Thomas Graf f703192a4f routing rules: adapt to unified routing rules
- Use FRA_ definitions
- Removed obsoleted fields
- Added fwmask and goto support
2010-10-29 12:48:46 +02:00
Thomas Graf 1eccb7b99c Revert "routing rules: mark support"
This reverts commit ee88c71d16.
2010-10-29 11:52:22 +02:00
Thomas Graf 858527622a Revert "Include RTA_MARK in routing rule messages"
This reverts commit 6862c6592a.
2010-10-29 11:52:08 +02:00
Thomas Graf 48cdb1fe66 Support RT_TABLE_COMPAT 2010-10-29 02:06:14 +02:00
Thomas Graf 2e6d49784b Support neighbour flag NTF_USE 2010-10-29 02:00:53 +02:00
Thomas Graf 873a64e2c1 Support for 64bit link counters IFLA_STATS64 2010-10-29 01:58:27 +02:00
Thomas Graf 6d434415ad Updated arp and ethernet codes 2010-10-29 01:48:13 +02:00
Thomas Graf 6862c6592a Include RTA_MARK in routing rule messages 2010-10-29 01:38:10 +02:00
Thomas Graf ee88c71d16 routing rules: mark support
Obsolete RTA_PROTOINFO code and parse RTA_MARK

rtnl_rule_set_mark(rule, mark)
rtnl_rule_get_mark(rule)

now access the mark as in firewall mark
2010-10-29 01:34:15 +02:00
Thomas Graf 691905bc56 cgroup classifier improvements
- enabled again
 - ematch support
 - cli tools module

Example:
	nl-qdisc-add --dev eth0 --parent root --id 1: htb
	nl-cls-add --dev eth0 --parent 1: --id dead: cgroup
	nl-class-add --dev eth0 --parent 1: --id 1:<CGROUP> htb --rate 77mbit
2010-10-29 00:51:11 +02:00
Thomas Graf 2f867686ac basic: Only add ematches to message if available 2010-10-29 00:45:45 +02:00
Thomas Graf d7a561a137 Tons of ematch work
- Fixes a bunch of bugs related to ematches
 - Adds support for the nbyte ematch
 - Adds a bison/flex parser for ematch expressions, expressions
   may look like this:
      ip.length > 256 && pattern(ip6.src = 3ffe::/16)
   documenation on syntax follows
 - adds ematch support to the basic classifier (--ematch EXPR)
2010-10-29 00:20:42 +02:00
Thomas Graf e1eacd6b16 Fix use of uninitialized data at the end of netlink message
The netlink message buffer is preallocated to a page and later
expanded as needed. Everything was properly paded and zeroed
out except for the unused part at the end. Use calloc() to
allocate the buffer.
2010-10-29 00:17:07 +02:00
Thomas Graf d0e564548f Avoid memcpy()/memset() when reserving space for nested attributes 2010-10-29 00:16:40 +02:00
Thomas Graf 0fe5b29423 Extended pktloc to support nbyte locations for ipv6, etc.
The alignment column/field now also takes a number, specifying
the length in bytes of the field described by the location
2010-10-29 00:14:34 +02:00
Thomas Graf 65e386c8ba Packet location updates
This patch includes various bugfixes in the packet location parser.
Namely it removes two memory leaks if parsing fails. The parser is
correctly quit if an allocation error occurs and it is no longer
possible to add duplicates.

It removes the possibility to differ between net and host byteorder.
This is better done in the actual classifiers as it makes more sense
to specify this together with the value to compare against.

The patch also extends the API to add new packet locations via
rtnl_pktloc_add().

It introduces reference counting, therefore you now have to give
back packet locations with rtnl_pktloc_put() after looking them up
with rtnl_pktloc_lookup(). But you are allowed to keep using them
if the packet location file has been reread.

The packet location file now also understands "eth", "ip", and
"tcp" for "link", "net", and "transport".

A --list option has been added to nl-pktloc-lookup to list all
packet location definitions

A --u32=VALUE option has been added to let nl-pktloc-lookup print
the definition in iproute2's u32 selector style.

A manual page has been written for nl-pktloc-lookup.

Finally, nl-pktloc-lookup has been made installable.
2010-10-27 01:21:50 +02:00
Thomas Graf b57a697ef1 nl-cls-* tools
cli based tools to add/update/list/delete classifiers
2010-10-26 22:30:02 +02:00
Thomas Graf 4c6d1c5dfb Unified TC attributes interface
So far all common tc atttributes were accessed via specific functions, i.e.
rtnl_class_set_parent(), rtnl_qdisc_set_parent(), rtnl_cls_set_parent()
which implied a lot of code duplication. Since all tc objects are derived
from struct rtnl_tc and these common attributes are already stored in there
this patch removes all type specific functions and makes rtnl_tc_* attribute
functions public.

        rtnl_qdisc_set_parent(qdisc, 10);

becomes:

        rtnl_tc_set_parent((struct rtnl_tc *) qdisc, 10);

This patch also adds the following new attributes to tc objects therefore
removing them as tc specific attributes:
 - mtu
 - mpu
 - overhead

This allows for the rate table calculations to be unified as well taking into
account the new kernel behavior to take care of overhead automatically.
2010-10-26 12:54:33 +02:00
Thomas Graf b9d965b01b Update include/linux header copies
Adapts ratespec code taking into account that the kernel now takes
care of overhead calculations.
2010-10-21 19:47:14 +02:00
Thomas Graf 420438c71f Remove NL_DUMP_ENV code
Dumping objects as environment variables has never been implemented
completely and only increases the size of the library for no real
purpose. Integration into scripts is better achieved by implementing
a python module anyway.
2010-10-20 15:32:45 +02:00
Thomas Graf 27883b0f9b nl-class-add tool
Adds a cli based tool to add/update traffic classes. This tool requires
each class to be supported via the respetive qdisc module in
pkglibdir/cli/qdisc/$name.so.

Syntax:
nl-class-add --dev eth2 --parent 1: --id 1:1 htb --rate 100mbit
nl-class-add --update --dev eth2 --id 1:1 htb --rate 200mbit
2010-10-20 14:57:39 +02:00
Thomas Graf 18848090f9 pfifo/bfifo qdisc support for cli libs 2010-10-19 16:51:55 +02:00
Thomas Graf 757592ec1b classid database
A database to resolve qdisc/class names to classid values and vice versa.
The function rtnl_tc_handle2str() and rtnl_tc_str2handle() will resolve
names automatically.

A CLI based tool nl-classid-lookup is provided to integrate the database
into existing iproute2 scripts.
2010-10-19 16:31:23 +02:00
Thomas Graf fa89403149 HTB: Append TCA_OPTIONS even if no options are set
The kernel requires the TCA_OPTIONS{TCA_HTB_INIT} attribute to be
present even if the default values are to be used.
2010-10-19 13:10:26 +02:00
Thomas Graf c0cd587dfc nl-qdisc-add tool
Adds a cli based tool to add/update/replace qdiscs. This tool requires
each qdisc to be supported via a dynamic loadable module in
pkglibdir/cli/qdisc/$name.so.

So far HTB and blackhole have been implemented.

Syntax:
nl-qdisc-add --dev eth2 --parent root --id 1: htb --r2q=5
nl-qdisc-add --update-only --dev eth2 --id 1: htb --r2q=10
2010-10-19 13:06:42 +02:00
Thomas Graf 3229b32e39 - Prepare for 2.1.x tree
- Bump interface number, we will break API in the development tree
2010-10-14 13:56:46 +02:00
dima 2dbc1ca76c Generic Netlink multicast groups support
I have a patch against commit d378220c96
extending libnl with a facility to receive generic netlink messages sent
to multicast groups.

Essentially it add one new function genl_ctrl_resolve_grp which
prototype looks like this
int genl_ctrl_resolve_grp(struct nl_sock *sk, const char *family_name,
        const char *grp_name)
It resolves  the family name and the group name to group id. Then
the returned id can be used in nl_socket_add_membership to subscribe
to multicast messages.

Besides that it adds two more functions

uint32_t nl_socket_get_peer_groups(struct nl_sock *sk)
void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups)

allowing to modify the socket peer groups field. So it's possible to
multicast messages from the user space using the legacy interface.
Looks like there is no way (or I was not able to find one?) to modify
the netlink socket destination group from the user space, when the
group id is greater then 32.
2010-10-14 13:46:02 +02:00
Thomas Graf 513e45ccce Don't include pktloc_syntax.h in BUILT_SOURCES 2010-10-13 16:50:33 +02:00
David Lamparter 2b3fabab9e route_obj: don't add empty destination to nlmsg
don't try to give the kernel an empty RTA_DST attribute. this would
previously happening on trying to delete the default route as returned
from the kernel. the kernel doesn't add a RTA_DST atttribute, so libnl
does nl_addr_alloc(0) and inserts a zero-length RTA_DST attribute into
the deletion request, which the kernel then refuses with ERANGE.

Signed-off-by: David Lamparter <equinox@diac24.net>
2010-10-13 15:21:14 +02:00
Andreas Bießmann cb05bbb0e2 automake: add ${top_builddir}/include to AM_CFLAGS
This patch enables out-of-source builds like this
  $ cd builddir && src_dir/configure && make

 Before this patch there was an error about missing netlink/version.h which
 is built by automake in top_builddir rather than top_srcdir which is already
 in include search path.

Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
2010-10-13 14:36:09 +02:00
Matthew L. Creech a172e3ccf0 Put preprocessor definitions in AM_CPPFLAGS
When an alternate kernel header include directory is added in
CPPFLAGS, the libnl build fails.  This is because the local copy of
kernel headers is added in AM_CFLAGS, which gets included after
CPPFLAGS in the automake-generated makefile.  Switching to AM_CPPFLAGS
fixes the problems.
2010-10-13 14:29:34 +02:00
Andreas Fett 4ab22ccd47 add user data to change_func_t for caches
the patch below adds the possibility to
pass user data to callbacks of type
change_func_t when using the nl_cache_mngr_*
family of functions.

If there is any better way to do this,
without duplicating the code in
cache_mngr.c please let me know.
2010-10-13 13:41:57 +02:00
Denys Fedorysychenko 86b6f6f629 Trivial fix for TBF memleak
Without this patch, running alloc / free cache loop  will lead to huge memory
leaks on machine with 3000 interfaces with tbf qdiscs.

Here was valgrind output:

==5580== 18,070,728 bytes in 347,514 blocks are definitely lost in loss record
32 of 32
==5580==    at 0x4025485: calloc (in /lib/valgrind/vgpreload_memcheck-x86-
linux.so)
==5580==    by 0x405F410: tbf_msg_parser (tbf.c:46)
==5580==    by 0x405302B: qdisc_msg_parser (qdisc.c:119)
==5580==    by 0x4033DC9: nl_cache_parse (cache.c:643)
==5580==    by 0x4033E7C: update_msg_parser (cache.c:460)
==5580==    by 0x4038A11: nl_recvmsgs (netlink-local.h:112)
==5580==    by 0x4034175: __cache_pickup (cache.c:483)
==5580==    by 0x40343FF: nl_cache_pickup (cache.c:516)
==5580==    by 0x403447D: nl_cache_refill (cache.c:698)
==5580==    by 0x4034AB7: nl_cache_alloc_and_fill (cache.c:198)
==5580==    by 0x4053216: rtnl_qdisc_alloc_cache (qdisc.c:388)
==5580==    by 0x80489DB: main (in /home/root/nltest)

Patch complied and tested for same test case, no more leaks anymore.
2010-10-13 13:24:25 +02:00
Thomas Graf 7cf52dd94b Let git ignore generated pktloc source files 2010-07-03 15:56:07 +02:00
Thomas Graf 0fa04772ab Fix compile warning in utils.c 2010-07-03 15:17:04 +02:00
Thomas Graf 256d7e723c Fix compile warning in nl.c 2010-07-03 15:15:12 +02:00
Thomas Graf db5bd57899 Packet Location Interface 2010-07-02 14:06:59 +02:00
Patrick McHardy 3c28aa5dca Fix rule attribute comparison
Rules don't have unique identifiers, so all attributes are compared
by initializing the ID mask to ~0. This doesn't work however since
nl_object_identical verifies whether the ID attributes are actually
present before comparing the objects, which is never the case.

Work around by using the intersection of present attributes when
comparing two rule objects.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:43:18 +02:00
Patrick McHardy 0e4f54d288 addr: add NL_DUMP_ENV function
Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:43:01 +02:00
Patrick McHardy f5f49c2248 addr: restore anycast functions
Seems it got lost during some cleanups.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:42:53 +02:00
Patrick McHardy 8290725718 neigh: fix id_attrs to include ifindex
Neighbour entries for the same destination may exist on multiple
interfaces. Include the interface in the ID attributes.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:42:40 +02:00
Patrick McHardy ba1bd9050d cache: properly invoke change_cb for deleted objects in nl_cache_resync()
When resyncing a cache, there are no delete messages, so they need to
be synthesized for deleted objects.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-04-19 12:42:27 +02:00
Jose Ignacio Naranjo Hernández 52d6b8b9ee Fix a bug when calculating ticks_per_usec
I've noticed a wrong behavior when setting up some delays in a netem
qdisc.  I will try to make the things easier for the reader describing
the calls path.

To set up a delay (or jitter...) I use 'rtnl_netem_set_delay' which
requires an int parameter that tells the delay in micro seconds. Inside
this func, the delay is set up with the help of 'nl_us2ticks', which is
just an arithmetic operation (us * ticks_per_usec), where us is the
input parameter and ticks_per_usec is a global variable initialized in
'get_psched_settings'. And here is the problem:

If this variable is going to be calculated using '/proc/net/psched', I
think the file scan is not done properly.

I don't understand what the meaning of the asterisk is here:

int r = fscanf(fd, "%08x%08x%08x%*08x", &tick, &us, &nom);
if (4 == r && nom == 1000000 && !got_tick)
        ticks_per_usec = (double)tick/(double)us;

The execution path never gets in the if statement, because r is always
3, and if the fourth parameter is read (avoiding the asterisk), there is
no variable to store it in, so it comes a segv. In my opinion we can get
rid of the if statement, because I think the proc psched file has always
a fixed format of 4 parameters, and 'nom' is always 1000000
(http://lxr.linux.no/#linux+v2.6.32/net/sched/sch_api.c#L1678).

Find attached a patch I did, if I am correct.
2010-03-10 16:18:54 +01:00
Karl Hiramoto cafdaa4e06 new function nfnl_queue_msg_send_verdict_payload()
nfnl_queue_msg_send_verdict_payload() will to send the verdict, mark,
and possibly changed payload through the netlink socket.

Add a few docbook comments in other funcs.

Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
2010-03-10 16:02:01 +01:00
Karl Hiramoto 27c505eb89 new feature nl_send_iovec(), nl_auto_complete() and code refactoring.
Create new function nl_send_iovec() to be used to send multiple 'struct iovec'
through the netlink socket.  This will be used for NF_QUEUE, to send
packet payload of a modified packet.

Refactor nl_send() to use nl_send_iovec() sending a single struct iovec.

Create new function nl_auto_complete() by refactoring nl_send_auto_complete(),
so other functions that call nl_send may also use nl_auto_complete()

Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
2010-03-10 16:01:46 +01:00
Denys Fedoryschenko ff76549013 one more fix, u32.c
One more segfault, also nl-tctree-list , fix
Probably need reformat for better look
Patch attached
2009-12-07 16:27:59 +01:00
Denys Fedoryschenko 52510e7d39 invalid comma cause segfault for nl-tctree-list, tbf.c
I notice segfault while running nl-tctree-list for tbf qdisc.

Patch that fix this typo is attached.
2009-12-07 16:23:48 +01:00
Patrick McHardy 8d2bb90726 libnl: add ERANGE to errno translation
Signed-off-by: Patrick McHardy <kaber@trash.net>
2009-11-10 11:29:07 +01:00
Patrick McHardy fed168212e libnl: fix automake breakage
libnl-route must be handled before libnl-nf in lib_LTLIBRARIES since
the later depends on the former. Additionally nf-monitor, nl-list-caches,
nl-list-sockets and nl-util-addr have been dropped from the Makefile.

Signed-off-by: Patrick McHardy <kaber@trash.net>
2009-11-10 11:28:51 +01:00
Thomas Graf dc273a12da - Compile with _GNU_SOURCE
- Fixed classifier.c -> cls.c
2009-09-03 00:01:33 +02:00
Thomas Graf f946cfaa3a Merge branch 'master' of git://dev.medozas.de/libnl
Conflicts:
	lib/Makefile
	src/Makefile
2009-09-02 23:41:03 +02:00
olc 2ead49f0d5 Add support for getting and deleting queueing classes. 2009-09-02 21:10:48 +02:00