Skip to contentSkip to conversation

netlink NETLINK_ROUTE failure & Can the kernel really handle IPv6 properly

DISCUSSION Ulf Samuelsson 6 participants 9 messages Oct 1, 2014 – Oct 6, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Trying to write a kernel module handing NETLINK_ROUTE messages for a 3.4.x kernel.

After building the module, it fails to load on my PowerPC P2020 target. Reason is that the "netlink_kernel_create" fails.

---------------------------------------
struct *sock nls;

...
static int __init my_init (...)
{
...
nls = netlink_kernel_create( &init_net, NETLINK_ROUTE, 0, my_rcv,

NULL, THIS_MODULE);
    if (!nls) {
            return -ENOMEM;
    }

...
}
----------------------------------------
netlick_kernel_create returns 0, so the kernel module fails.

Is there anything wrong wth the call to netlink_kernel_create ?

Goggling show that some code uses "__net_init".
Not sure what that means.

Other code uses a mutex, instead of NULL.
Does NETLINK_ROUTE require a mutex?

All ideas are welcome-

==============
BTW, the problem I am trying to solve is how to connect to an I/F with an IPv6 link-local address.

An existing kernel module waits for a NETDEV_UP event, and then tries to communicate with the link-local address.

This will fail, because (according to a colleague) the I/F enters a "tentative" state, where it is trying to decide if it is unique or not.
It will remain in that state for 1-2 seconds, and only afterwards is the link-local address available for normal use.

The guys writing the module, claim that the kernel is using NETDEV_UP. There is very little code in the kernel using NETLINK_ROUTE, even in latest stable. It is using NETDEV_UP.

If my colleague is right, the kernel really cannot handle IPv6 link-local addresses properly.

Signature · 2 lines
Best Regards
Ulf Samuelsson
#1 lore raw

Hello,

Quoted 14 lines · Ulf Samuelsson

BTW, the problem I am trying to solve is how to connect to an I/F with an IPv6 link-local address.

An existing kernel module waits for a NETDEV_UP event, and then tries to communicate
with the link-local address.

This will fail, because (according to a colleague) the I/F enters a "tentative" state,
where it is trying to decide if it is unique or not.
It will remain in that state for 1-2 seconds, and only afterwards is the link-local address
available for normal use.

Quoted 7 lines

The guys writing the module, claim that the kernel is using NETDEV_UP. There is very little code in the kernel using NETLINK_ROUTE, even in latest stable.
It is using NETDEV_UP.

If my colleague is right, the kernel really cannot handle IPv6 link-local addresses properly.

Sorry, I cannot really follow you, can you send example code or be a bit more precise?

Thanks,
Hannes

#2 lore raw

This is the significant code, and it is wrong.

static struct notifier_block my_ipv6_address_notifier =
{
my_ipv6_address_notifier_cb,
NULL,
0
};

register_inet6addr_notifier (&my_ipv6_address_notifier );

int
my_ipv6_address_notifier_cb (struct notifier_block *self,
unsigned long event, void *val)
{
struct inet6_ifaddr *ifaddr = (struct inet6_ifaddr *)val;

/* We are only interested in address add/delete events */ /* IPv6 address add comes as NETDEV_UP and delete comes as
* NETDEV_DOWN
*/
if ((event != NETDEV_UP) && (event != NETDEV_DOWN))
return ret;

if (ifaddr == NULL)
return ret;
/* Now that we are sure that it is a IPv6 address being added deleted,
* verify that it is a link local address.
*/
if (!IPV6_IS_ADDR_LINKLOCAL (&ifaddr->addr))

   {
     return ret;

}
...
send_message_to_app(LINK_LOCAL_UP, ip);
...
return ret;
}

Application tries to send message to "ip" and fails, because the link-local adress is still in "tentative state"

Best Regards
Ulf Samuelsson
[email protected]
+46 (722) 427 437

Quoted 36 lines

1 okt 2014 kl. 23:30 skrev Hannes Frederic Sowa <[email protected]>:

Hello,

Quoted 15 lines · Ulf Samuelsson

BTW, the problem I am trying to solve is how to connect to an I/F with an IPv6 link-local address.

An existing kernel module waits for a NETDEV_UP event, and then tries to communicate
with the link-local address.

This will fail, because (according to a colleague) the I/F enters a "tentative" state,
where it is trying to decide if it is unique or not.
It will remain in that state for 1-2 seconds, and only afterwards is the link-local address
available for normal use.

Quoted 7 lines

The guys writing the module, claim that the kernel is using NETDEV_UP. There is very little code in the kernel using NETLINK_ROUTE, even in latest stable.
It is using NETDEV_UP.

If my colleague is right, the kernel really cannot handle IPv6 link-local addresses properly.

Sorry, I cannot really follow you, can you send example code or be a bit more precise?

Thanks,
Hannes
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 41 lines · Ulf samuelsson

This is the significant code, and it is wrong.

static struct notifier_block my_ipv6_address_notifier =

 {
   my_ipv6_address_notifier_cb,
   NULL,
   0

};

register_inet6addr_notifier (&my_ipv6_address_notifier );

int
my_ipv6_address_notifier_cb (struct notifier_block *self,
unsigned long event, void *val)
{
struct inet6_ifaddr *ifaddr = (struct inet6_ifaddr *)val;

/* We are only interested in address add/delete events */ /* IPv6 address add comes as NETDEV_UP and delete comes as
* NETDEV_DOWN
*/
if ((event != NETDEV_UP) && (event != NETDEV_DOWN))
return ret;

if (ifaddr == NULL)
return ret;
/* Now that we are sure that it is a IPv6 address being added deleted,
* verify that it is a link local address.
*/
if (!IPV6_IS_ADDR_LINKLOCAL (&ifaddr->addr))

   {
     return ret;

}
...
send_message_to_app(LINK_LOCAL_UP, ip);
...
return ret;
}

Quoted 2 lines

Application tries to send message to "ip" and fails, because the link-local adress is still in "tentative state"

It seems to me that a better architecture would be to have the app itself listen for RTM_NEWADDR netlink event and look for lack of IFA_F_TENTATIVE in the IFA_FLAGS attribute. Using a kernel module to do the same thing seems pretty wrong.

Dan

Quoted 46 lines

Best Regards
Ulf Samuelsson
[email protected]
+46 (722) 427 437

Quoted 30 lines

1 okt 2014 kl. 23:30 skrev Hannes Frederic Sowa <[email protected]>:

Hello,

Quoted 15 lines · Ulf Samuelsson

BTW, the problem I am trying to solve is how to connect to an I/F with an IPv6 link-local address.

An existing kernel module waits for a NETDEV_UP event, and then tries to communicate
with the link-local address.

This will fail, because (according to a colleague) the I/F enters a "tentative" state,
where it is trying to decide if it is unique or not.
It will remain in that state for 1-2 seconds, and only afterwards is the link-local address
available for normal use.

Quoted 7 lines

The guys writing the module, claim that the kernel is using NETDEV_UP. There is very little code in the kernel using NETLINK_ROUTE, even in latest stable.
It is using NETDEV_UP.

If my colleague is right, the kernel really cannot handle IPv6 link-local addresses properly.

Sorry, I cannot really follow you, can you send example code or be a bit more precise?

Quoted 6 lines

Thanks,
Hannes
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 42 lines · Dan Williams
Quoted 41 lines · Ulf samuelsson

This is the significant code, and it is wrong.

static struct notifier_block my_ipv6_address_notifier =

  {
    my_ipv6_address_notifier_cb,
    NULL,
    0

};

register_inet6addr_notifier (&my_ipv6_address_notifier );

int
my_ipv6_address_notifier_cb (struct notifier_block *self,
unsigned long event, void *val)
{
struct inet6_ifaddr *ifaddr = (struct inet6_ifaddr *)val;

/* We are only interested in address add/delete events */ /* IPv6 address add comes as NETDEV_UP and delete comes as
* NETDEV_DOWN
*/
if ((event != NETDEV_UP) && (event != NETDEV_DOWN))

    return ret;

if (ifaddr == NULL)

    return ret;
  /* Now that we are sure that it is a IPv6 address being added deleted,
   * verify that it is a link local address.
   */
  if (!IPV6_IS_ADDR_LINKLOCAL (&ifaddr->addr))
    {
      return ret;
    }

...
send_message_to_app(LINK_LOCAL_UP, ip);
...
return ret;
}

Quoted 8 lines
Quoted 2 lines

Application tries to send message to "ip" and fails, because the link-local adress is still in "tentative state"

It seems to me that a better architecture would be to have the app itself listen for RTM_NEWADDR netlink event and look for lack of IFA_F_TENTATIVE in the IFA_FLAGS attribute. Using a kernel module to do the same thing seems pretty wrong.

Dan

Thanks, Maybe you are right but I do not have all the details.

The kernel module is part of a driver for a Broadcom router chip. The guys writing the driver might want to know as well.

I will see what they say.

Best Regards,
Ulf Samuelsson

Quoted 50 lines
Quoted 41 lines

Best Regards
Ulf Samuelsson
[email protected]
+46 (722) 427 437

Quoted 29 lines

1 okt 2014 kl. 23:30 skrev Hannes Frederic Sowa <[email protected]>:

Hello,

Quoted 15 lines · Ulf Samuelsson

BTW, the problem I am trying to solve is how to connect to an I/F with an IPv6 link-local address.

An existing kernel module waits for a NETDEV_UP event, and then tries to communicate
with the link-local address.

This will fail, because (according to a colleague) the I/F enters a "tentative" state,
where it is trying to decide if it is unique or not.
It will remain in that state for 1-2 seconds, and only afterwards is the link-local address
available for normal use.

Quoted 7 lines

The guys writing the module, claim that the kernel is using NETDEV_UP. There is very little code in the kernel using NETLINK_ROUTE, even in latest stable.
It is using NETDEV_UP.

If my colleague is right, the kernel really cannot handle IPv6 link-local addresses properly.

Sorry, I cannot really follow you, can you send example code or be a bit more precise?

Quoted 6 lines

Thanks,
Hannes
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Dan Williams
Quoted 42 lines · Dan Williams
Quoted 41 lines · Ulf samuelsson

This is the significant code, and it is wrong.

static struct notifier_block my_ipv6_address_notifier =

  {
    my_ipv6_address_notifier_cb,
    NULL,
    0

};

register_inet6addr_notifier (&my_ipv6_address_notifier );

int
my_ipv6_address_notifier_cb (struct notifier_block *self,
unsigned long event, void *val)
{
struct inet6_ifaddr *ifaddr = (struct inet6_ifaddr *)val;

/* We are only interested in address add/delete events */ /* IPv6 address add comes as NETDEV_UP and delete comes as
* NETDEV_DOWN
*/
if ((event != NETDEV_UP) && (event != NETDEV_DOWN))

    return ret;

if (ifaddr == NULL)

    return ret;
  /* Now that we are sure that it is a IPv6 address being added deleted,
   * verify that it is a link local address.
   */
  if (!IPV6_IS_ADDR_LINKLOCAL (&ifaddr->addr))
    {
      return ret;
    }

...
send_message_to_app(LINK_LOCAL_UP, ip);
...
return ret;
}

Quoted 8 lines
Quoted 2 lines

Application tries to send message to "ip" and fails, because the link-local adress is still in "tentative state"

It seems to me that a better architecture would be to have the app itself listen for RTM_NEWADDR netlink event and look for lack of IFA_F_TENTATIVE in the IFA_FLAGS attribute. Using a kernel module to do the same thing seems pretty wrong.

Dan

OK, got more information. This is part of a fairly large and complex system.

The kernel module is a control module which collects information both from the kernel and from H/W, and talks to a userspace interface manager.

There is a proprietary management application which is used to configure the stack. This talks to the interface manager to handle different operations for IPv6.

The kernel module needs to know when interfaces are ready to use, I.E: know when it exits "tentative" mode to do its job properly, so the kernel module has to listen for RTM_NEWADDR.

In a simpler system, your approach would be OK.

Best Regards,
Ulf Samuelsson

Quoted 50 lines
Quoted 41 lines

Best Regards
Ulf Samuelsson
[email protected]
+46 (722) 427 437

Quoted 29 lines

1 okt 2014 kl. 23:30 skrev Hannes Frederic Sowa <[email protected]>:

Hello,

Quoted 15 lines · Ulf Samuelsson

BTW, the problem I am trying to solve is how to connect to an I/F with an IPv6 link-local address.

An existing kernel module waits for a NETDEV_UP event, and then tries to communicate
with the link-local address.

This will fail, because (according to a colleague) the I/F enters a "tentative" state,
where it is trying to decide if it is unique or not.
It will remain in that state for 1-2 seconds, and only afterwards is the link-local address
available for normal use.

Quoted 7 lines

The guys writing the module, claim that the kernel is using NETDEV_UP. There is very little code in the kernel using NETLINK_ROUTE, even in latest stable.
It is using NETDEV_UP.

If my colleague is right, the kernel really cannot handle IPv6 link-local addresses properly.

Sorry, I cannot really follow you, can you send example code or be a bit more precise?

Quoted 6 lines

Thanks,
Hannes
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw

From: Ulf Samuelsson <[email protected]>
Date: Fri, 3 Oct 2014 09:59:39 +0200

Quoted 9 lines

The kernel module is a control module which collects information both from the kernel and from H/W, and talks to a userspace interface manager.

There is a proprietary management application which is used to configure the stack.
This talks to the interface manager to handle different operations for IPv6.

Quoted 5 lines

The kernel module needs to know when interfaces are ready to use, I.E: know when it exits "tentative" mode to do its job properly, so the kernel module has to listen for RTM_NEWADDR.

In a simpler system, your approach would be OK.

Sorry, we're not going to help you with a proprietary driver of this kind.

They should really just follow our upstream efforts to design a usable kernel framework for bridge and routing hardware offloads.

#8 lore raw
In reply to Ulf Samuelsson
Quoted 2 lines · Ulf Samuelsson
    nls = netlink_kernel_create( &init_net, NETLINK_ROUTE, 0, my_rcv, NULL, THIS_MODULE);

Kernel already creates NETLINK_ROUTE type netlink,
you can not create another kernel side NETLINK_ROUTE netlink socket.

#7 lore raw
In reply to David Miller
Quoted 16 lines · David Miller

From: Ulf Samuelsson <[email protected]>
Date: Fri, 3 Oct 2014 09:59:39 +0200

Quoted 13 lines

The kernel module is a control module which collects information both from the kernel and from H/W, and talks to a userspace interface manager.

There is a proprietary management application which is used to configure the stack.
This talks to the interface manager to handle different operations for IPv6.

The kernel module needs to know when interfaces are ready to use, I.E: know when it exits "tentative" mode to do its job properly, so the kernel module has to listen for RTM_NEWADDR.

Quoted 6 lines
Quoted 1 line

In a simpler system, your approach would be OK.

Sorry, we're not going to help you with a proprietary driver of this kind.

They should really just follow our upstream efforts to design a usable kernel framework for bridge and routing hardware offloads.

Whether to use a kernel framework or not is not my decision, and I don't even work with that code.

What should interest the community is that a lot of stuff is probably not working properly, when IPv6 link-local addresses are used.

Listening for NETDEV_UP, which is used in many places in the kernel, seems incorrect, since connection to the link-local address will fail until the link-local address is verified. It is not immediately obvious, since after 1-2 seconds the problem disappears.

For that, listening to the RTM_NEWADDR seems mandatory, so any framework would benefit from a solution as well.

Best Regards,
Ulf Samuelsson

'