[PATCH 2/2] inet6: add link IPv6 address generation mode support

Thomas Haller thaller at redhat.com
Fri Jul 25 15:03:19 PDT 2014


On Fri, 2014-07-25 at 14:36 -0500, Dan Williams wrote:
> Signed-off-by: Dan Williams <dcbw at redhat.com>
> ---
> + * @return 0 on success
> + * @return -NLE_NOATTR configuration setting not available
> + * @return -NLE_INVAL generation mode unknown. If the link was received via
> + *                    netlink, it means that address generation mode is not
> + *                    supported by the kernel.
> + */
> +int rtnl_link_inet6_get_addr_gen_mode(struct rtnl_link *link, uint8_t *mode)
> +{
> +	struct inet6_data *id;
> +
> +	if (!(id = rtnl_link_af_alloc(link, &inet6_ops)))
> +		return -NLE_NOATTR;

I think this should not be NLE_NOATTR. The same bug is in
https://github.com/thom311/libnl/blob/9dc6e6da90016a33929f262bea0187396e1a061b/lib/route/link/inet.c#L245 (I will sent a separate patch for that).



How about the following fixup?
[[ https://github.com/thom311/libnl/compare/master...dcbw/inet6_addr_gen ]]


diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c
index 43bc387..201d18c 100644
--- a/lib/route/link/inet6.c
+++ b/lib/route/link/inet6.c
@@ -168,7 +168,7 @@ static int inet6_parse_protinfo(struct rtnl_link *link, struct nlattr *attr,
 
     if (tb[IFLA_INET6_ADDR_GEN_MODE])
          i6->i6_addr_gen_mode = nla_get_u8 (tb[IFLA_INET6_ADDR_GEN_MODE]);
- 
+
     /*
      * Due to 32bit data alignment, these addresses must be copied to an
      * aligned location prior to access.
@@ -537,7 +537,7 @@ int rtnl_link_inet6_get_addr_gen_mode(struct rtnl_link *link, uint8_t *mode)
 {
     struct inet6_data *id;
 
-    if (!(id = rtnl_link_af_alloc(link, &inet6_ops)))
+    if (!(id = rtnl_link_af_data(link, &inet6_ops)))
          return -NLE_NOATTR;
 
     if (id->i6_addr_gen_mode == I6_ADDR_GEN_MODE_UNKNOWN)
@@ -555,14 +555,14 @@ int rtnl_link_inet6_get_addr_gen_mode(struct rtnl_link *link, uint8_t *mode)
  * Sets the link's IPv6 link-local address generation mode.
  *
  * @return 0 on success
- * @return -NLE_NOATTR configuration setting not available
+ * @return -NLE_NOMEM could not allocate inet6 data
  */
 int rtnl_link_inet6_set_addr_gen_mode(struct rtnl_link *link, uint8_t mode)
 {
     struct inet6_data *id;
 
     if (!(id = rtnl_link_af_alloc(link, &inet6_ops)))
-         return -NLE_NOATTR;
+         return -NLE_NOMEM;
 
     id->i6_addr_gen_mode = mode;
     return 0;





You included the kernel header file 'include/uapi/linux/if_link.h' from
commit bc91b0f07ada5535427373a4e2050877bcc12218. This is not yet in
upstream master. We can either wait until it gets merged for v3.17 or
already merge it now.



Thomas


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20140726/156d9124/attachment-0001.sig>


More information about the libnl mailing list