Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Quagga: Dev

[PATCH] Enables zebra to be in sync with kernel routing tables.

 

 

Quagga dev RSS feed   Index | Next | Previous | View Threaded


igorm at etf

Oct 24, 2011, 8:29 AM

Post #1 of 16 (2532 views)
Permalink
[PATCH] Enables zebra to be in sync with kernel routing tables.

From: Igor Maravic <igorm [at] etf>

Enables zebra to be in sync with kernel routing tables.
It deletes inactive routes from zebra's rib when interfece goes done,
or when it loses carrier. When interface loses carrier, it deletes kernel ipv6 routes,
which are linked with interface, from the kernel. Kernel ipv4 routes are deleted directly in kernel.

Signed-off-by: Igor Maravic <igorm [at] etf>
---
:100644 100644 12f3fa5... 02e8e35... M zebra/zebra_rib.c
zebra/zebra_rib.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 12f3fa5..02e8e35 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -758,6 +758,9 @@ rib_match_ipv6 (struct in6_addr *addr)
#define RIB_SYSTEM_ROUTE(R) \
((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)

+#define RIB_KERNEL_ROUTE(R) \
+ ((R)->type == ZEBRA_ROUTE_KERNEL)
+
/* This function verifies reachability of one given nexthop, which can be
* numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored
* in nexthop->flags field. If the 4th parameter, 'set', is non-zero,
@@ -1128,6 +1131,10 @@ rib_process (struct route_node *rn)
redistribute_delete (&rn->p, fib);
if (! RIB_SYSTEM_ROUTE (fib))
rib_uninstall_kernel (rn, fib);
+ else if(RIB_KERNEL_ROUTE (fib) && del == NULL){
+ rib_uninstall_kernel (rn, fib);
+ del=fib;
+ }
UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);

/* Set real nexthop. */
--
1.7.4.1

_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


igorm at etf

Oct 24, 2011, 8:29 AM

Post #2 of 16 (2501 views)
Permalink
[PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

From: Igor Maravic <igorm [at] etf>

I did some testing of my own and came up to another solution for problem with kernel routes.
It's quite simple really. It resembles to Stephen Hemminger patch for linux kernel(http://kerneltrap.org/mailarchive/linux-netdev/2008/6/2/2010564)
because if link detection is enabled, when carrier is lost, all routes from the kernel,linked to that interface, are deleted both in kernel and zebra.

1. when link detection is disabled and carrier was lost, only ipv4 routes that are linked to that interface will be deleted. They are deleted in kernel,
and after that Quagga receives RTM_DELROUTE message, and deletes them normally. All ipv6 routes, linked to that interface, are intact.
2. when link detection is enabled and carrier was lost, interface is declared as down. Then all routes that are linked to that interface are deleted
from zebra's fib. To be sure that zebra's fib is in sync with kernel routing table, if route is from kernel(RIB_KERNEL_ROUTE (fib))
and it wasn't previously marked for deletion(del == NULL), we call function rib_uninstall_kernel and after that we mark it to be deleted from rib (del=fib).
If route was previously deleted from kernel, rib_uninstall_kernel won't have any effect. But if the route still exists in kernel, it will be deleted.
3. when interface is manually set to down, all routes linked to that interface are deleted in kernel, and they are deleted from zebra's rib.

works perfectly with Joakim Tjernlund's patch (http://lists.quagga.net/pipermail/quagga-dev/2009-January/007704.html). Unfortunatly that patch isn't applied in to main stream Quagga.

BR
Igor Maravić

Igor Maravic (1):
Enables zebra to be in sync with kernel routing tables.

zebra/zebra_rib.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

--
1.7.4.1

_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


igorm at etf

Oct 25, 2011, 1:28 AM

Post #3 of 16 (2491 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

What should I do, to have my patch applied to mainstream Quagga?

2011/10/24 <igorm [at] etf>:
> From: Igor Maravic <igorm [at] etf>
>
> I did some testing of my own and came up to another solution for problem with kernel routes.
> It's quite simple really. It resembles to Stephen Hemminger patch for linux kernel(http://kerneltrap.org/mailarchive/linux-netdev/2008/6/2/2010564)
> because if link detection is enabled, when carrier is lost, all routes from the kernel,linked to that interface, are deleted both in kernel and zebra.
>
> 1. when link detection is disabled and carrier was lost, only ipv4 routes that are linked to that interface will be deleted. They are deleted in kernel,
> and after that Quagga receives RTM_DELROUTE message, and deletes them normally. All ipv6 routes, linked to that interface, are intact.
> 2. when link detection is enabled and carrier was lost, interface is declared as down. Then all routes that are linked to that interface are deleted
> from zebra's fib. To be sure that zebra's fib is in sync with kernel routing table, if route is from kernel(RIB_KERNEL_ROUTE (fib))
> and it wasn't previously marked for deletion(del == NULL), we call function rib_uninstall_kernel and after that we mark it to be deleted from rib (del=fib).
> If route was previously deleted from kernel, rib_uninstall_kernel won't have any effect. But if the route still exists in kernel, it will be deleted.
> 3. when interface is manually set to down, all routes linked to that interface are deleted in kernel, and they are deleted from zebra's rib.
>
> works perfectly with Joakim Tjernlund's patch (http://lists.quagga.net/pipermail/quagga-dev/2009-January/007704.html). Unfortunatly that patch isn't applied in to main stream Quagga.
>
> BR
> Igor Maravić
>
> Igor Maravic (1):
>  Enables zebra to be in sync with kernel routing tables.
>
>  zebra/zebra_rib.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
>
> --
> 1.7.4.1
>
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


infrastation at yandex

Oct 25, 2011, 1:58 AM

Post #4 of 16 (2486 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

25.10.2011, 12:28, "Igor Maravić" <igorm [at] etf>:
> What should I do, to have my patch applied to mainstream Quagga?

I have looked through the first half of the thread(s) and have seen the patch in assorted revisions, but I still don't get, which problem it fixes. Is there a bugzilla bug opened for it?

--
Denis Ovsienko
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


igorm at etf

Oct 25, 2011, 2:19 AM

Post #5 of 16 (2488 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

I don't know if there is bugzilla opened. I didn't opened it and I
stumbled upon this bug when I did quagga hacking of my own.

When interface goes down, or carrier is lost, and there are some
static routes that are made with ip route, they are going to be
deleted from kernel fib. That's what kernel does by default. But they
are not going to be deleted from zebra's fib. They will be declared
inactive. But when interface come up, or carrier is found, zebra will
declare them active even thou they don't exist in kernel's fib.
In my second patch I added call to the function rib_uninstall_kernel
(rn, fib); because ipv6 routes aren't deleted from the kernel when the
carrier is lost, like the ipv4 routes are. With the call to that
function they will be deleted from the kernel, just like ipv4 routes
are.

There is also another very important patch -
http://lists.quagga.net/pipermail/quagga-dev/2009-January/007704.html
I also think that it should be applied to the upstream quagga, but
Joakim Tjernlund, should tell you more about it.
BR
Igor

2011/10/25 Denis Ovsienko <infrastation [at] yandex>:
> 25.10.2011, 12:28, "Igor Maravić" <igorm [at] etf>:
>> What should I do, to have my patch applied to mainstream Quagga?
>
> I have looked through the first half of the thread(s) and have seen the patch in assorted revisions, but I still don't get, which problem it fixes. Is there a bugzilla bug opened for it?
>
> --
>    Denis Ovsienko
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev [at] lists
> http://lists.quagga.net/mailman/listinfo/quagga-dev
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


joakim.tjernlund at transmode

Oct 25, 2011, 3:42 AM

Post #6 of 16 (2488 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

>
> I don't know if there is bugzilla opened. I didn't opened it and I
> stumbled upon this bug when I did quagga hacking of my own.
>
> When interface goes down, or carrier is lost, and there are some
> static routes that are made with ip route, they are going to be
> deleted from kernel fib. That's what kernel does by default. But they
> are not going to be deleted from zebra's fib. They will be declared
> inactive. But when interface come up, or carrier is found, zebra will
> declare them active even thou they don't exist in kernel's fib.
> In my second patch I added call to the function rib_uninstall_kernel
> (rn, fib); because ipv6 routes aren't deleted from the kernel when the
> carrier is lost, like the ipv4 routes are. With the call to that
> function they will be deleted from the kernel, just like ipv4 routes
> are.
>
> There is also another very important patch -
> http://lists.quagga.net/pipermail/quagga-dev/2009-January/007704.html
> I also think that it should be applied to the upstream quagga, but
> Joakim Tjernlund, should tell you more about it.

I have, several times, done so. Search the archive because I am not doing
that again.

_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


gdt at ir

Oct 25, 2011, 4:35 AM

Post #7 of 16 (2489 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

When interface goes down, or carrier is lost, and there are some
static routes that are made with ip route, they are going to be
deleted from kernel fib. That's what kernel does by default. But they

Are you talking about only Linux, or is this more general? I have not
seen this on BSD. This behavior sounds odd to me, particularly deleting
routes on lost carrier.


igorm at etf

Oct 25, 2011, 4:44 AM

Post #8 of 16 (2492 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

I'm running Ubuntu with Linux kernel 2.6.38.8.

2011/10/25 Greg Troxel <gdt [at] ir>:
>
> When interface goes down, or carrier is lost, and there are some
> static routes that are made with ip route, they are going to be
> deleted from kernel fib. That's what kernel does by default. But they
>
> Are you talking about only Linux, or is this more general? I have not
> seen this on BSD. This behavior sounds odd to me, particularly deleting
> routes on lost carrier.
>
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev [at] lists
> http://lists.quagga.net/mailman/listinfo/quagga-dev
>
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


gdt at ir

Oct 25, 2011, 5:36 AM

Post #9 of 16 (2493 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

[top-posting, misquoting and spurious non-ascii whitespace repaired]

Igor Maravić <igorm [at] etf> writes:

>>> When interface goes down, or carrier is lost, and there are some
>>> static routes that are made with ip route, they are going to be
>>> deleted from kernel fib. That's what kernel does by default. But they
>>
>> Are you talking about only Linux, or is this more general? I have not
>> seen this on BSD. This behavior sounds odd to me, particularly deleting
>> routes on lost carrier.

> I'm running Ubuntu with Linux kernel 2.6.38.8.

Have you tried to understand if this is any other than a bug on your
particular system?

How do other programs deal with this?

So if on your particular OS version, you configure a single interface
and add a default route (or a route to some non-local prefix via another
host on the local network), and then that interface loses carrier for 10
seconds, are you saying that this route is deleted from the kernel fib?
If that's really true, I would suggest reporting a bug to Ubuntu or
Linux.


igorm at etf

Oct 25, 2011, 6:12 AM

Post #10 of 16 (2491 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

XORP doesn't read kernel routes.

Yes, on my OS when cable is unplugged for a 1 sec, all ipv4 routes
that are linked to that interface are deleted. IPv6 routes aren't
deleted. When interface is manually put down, all routes, ipv4 and
ipv6, that are linked to that interface are deleted.
I don't see that as a bug. If I want static routes, that are going to
be saved when interface goes down, I will configure them via quagga,
or XORP, not via ip route. I just want to have the same routing table
in zebra and in kernel.
BR
Igor

2011/10/25 Greg Troxel <gdt [at] ir>:
>
> [top-posting, misquoting and spurious non-ascii whitespace repaired]
>
> Igor Maravić <igorm [at] etf> writes:
>
>>>> When interface goes down, or carrier is lost, and there are some
>>>> static routes that are made with ip route, they are going to be
>>>> deleted from kernel fib. That's what kernel does by default. But they
>>>
>>> Are you talking about only Linux, or is this more general?  I have not
>>> seen this on BSD.  This behavior sounds odd to me, particularly deleting
>>> routes on lost carrier.
>
>> I'm running Ubuntu with Linux kernel 2.6.38.8.
>
> Have you tried to understand if this is any other than a bug on your
> particular system?
>
> How do other programs deal with this?
>
> So if on your particular OS version, you configure a single interface
> and add a default route (or a route to some non-local prefix via another
> host on the local network), and then that interface loses carrier for 10
> seconds, are you saying that this route is deleted from the kernel fib?
> If that's really true, I would suggest reporting a bug to Ubuntu or
> Linux.
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


sysoleg at yandex

Oct 25, 2011, 8:29 AM

Post #11 of 16 (2488 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

25.10.2011, 17:12, "Igor Maravić" <igorm [at] etf>:
> Yes, on my OS when cable is unplugged for a 1 sec, all ipv4 routes
> that are linked to that interface are deleted. IPv6 routes aren't

Just tested this on my home PC (Slackware, 2.6.37.6-smp kernel).
Static routes are NOT deleted on link down/up event. Could you
please disable Ubuntu's Network Manager and try again?


--
wbr, Oleg.
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


gdt at ir

Oct 25, 2011, 9:04 AM

Post #12 of 16 (2488 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

Yes, on my OS when cable is unplugged for a 1 sec, all ipv4 routes
that are linked to that interface are deleted. IPv6 routes aren't
deleted. When interface is manually put down, all routes, ipv4 and

It seems pretty obvious to me that the v4 static routes being deleted on
loss of link is a bug, and a departure from longstanding practice. It's
a huge clue that v4 and v6 behave differently.

Isn't there a netlink message from the kernel when the routes are
deleted? If not, that's a kernel bug.

From: "\"Oleg A. Arkhangelsky\"" <sysoleg [at] yandex>
[ubuntu network manager]

Thanks - it sounds like you have identified the source of the trouble.


igorm at etf

Oct 26, 2011, 1:07 AM

Post #13 of 16 (2474 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

You were right. It's network manager fault. When it deletes routes on
carrier lost, there is RTM_DELROUTE netlink message, that zebra
catches.
But there still remains the problem when interface is manually brought
down. Then all static routes, ipv4 and ipv6, are deleted. There are no
RTM_DELROUTE messages.

Do you think that deleteing static routes from zebra's fib, if
interface is down would be proper solution?
BR
Igor

Signed-off-by: Igor Maravic <igorm [at] etf>
---
:100644 100644 12f3fa5... 22912f0... M zebra/zebra_rib.c
zebra/zebra_rib.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 12f3fa5..22912f0 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -758,6 +758,9 @@ rib_match_ipv6 (struct in6_addr *addr)
#define RIB_SYSTEM_ROUTE(R) \
((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)

+#define RIB_KERNEL_ROUTE(R) \
+ ((R)->type == ZEBRA_ROUTE_KERNEL)
+
/* This function verifies reachability of one given nexthop, which can be
* numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored
* in nexthop->flags field. If the 4th parameter, 'set', is non-zero,
@@ -1128,6 +1131,9 @@ rib_process (struct route_node *rn)
redistribute_delete (&rn->p, fib);
if (! RIB_SYSTEM_ROUTE (fib))
rib_uninstall_kernel (rn, fib);
+ else if(RIB_KERNEL_ROUTE (fib) &&
!if_is_up(if_lookup_by_index(fib->nexthop->ifindex))){
+ del=fib;
+ }
UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);

/* Set real nexthop. */
--

2011/10/25 Greg Troxel <gdt [at] ir>:
>
> Yes, on my OS when cable is unplugged for a 1 sec, all ipv4 routes
> that are linked to that interface are deleted. IPv6 routes aren't
> deleted. When interface is manually put down, all routes, ipv4 and
>
> It seems pretty obvious to me that the v4 static routes being deleted on
> loss of link is a bug, and a departure from longstanding practice. It's
> a huge clue that v4 and v6 behave differently.
>
> Isn't there a netlink message from the kernel when the routes are
> deleted? If not, that's a kernel bug.
>
> From: "\"Oleg A. Arkhangelsky\"" <sysoleg [at] yandex>
> [ubuntu network manager]
>
> Thanks - it sounds like you have identified the source of the trouble.
>
>
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


gdt at ir

Oct 26, 2011, 6:00 AM

Post #14 of 16 (2470 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

But there still remains the problem when interface is manually brought
down. Then all static routes, ipv4 and ipv6, are deleted. There are no
RTM_DELROUTE messages.

Do you think that deleteing static routes from zebra's fib, if
interface is down would be proper solution?

No, I think the kernel should be fixed to send deletes for the routes it
is removing as the interface is brought down (if it's going to delete
such routes).


Can you explain how your patch doesn't break the other N operating
systems that don't automatically and silently delete routes?


igorm at etf

Oct 26, 2011, 6:58 AM

Post #15 of 16 (2463 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

I didn't think about it.
I'l think something else then.
BR
Igor

2011/10/26 Greg Troxel <gdt [at] ir>:
>
> But there still remains the problem when interface is manually brought
> down. Then all static routes, ipv4 and ipv6, are deleted. There are no
> RTM_DELROUTE messages.
>
> Do you think that deleteing static routes from zebra's fib, if
> interface is down would be proper solution?
>
> No, I think the kernel should be fixed to send deletes for the routes it
> is removing as the interface is brought down (if it's going to delete
> such routes).
>
>
> Can you explain how your patch doesn't break the other N operating
> systems that don't automatically and silently delete routes?
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


igorm at etf

Oct 27, 2011, 1:16 AM

Post #16 of 16 (2449 views)
Permalink
Re: [PATCH] Enables zebra to be in sync with kernel routing tables. [In reply to]

I think that it is easier to fix Quagga, then Linux kernel.
I just added check if Quagga is running on Linux, so my patch is going
to target only Linux OS, and it wont break other OS-s
BR
Igor

Signed-off-by: Igor Maravic <igorm [at] etf>
---
:100644 100644 12f3fa5... ee0a53e... M zebra/zebra_rib.c
zebra/zebra_rib.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 12f3fa5..ee0a53e 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -758,6 +758,9 @@ rib_match_ipv6 (struct in6_addr *addr)
#define RIB_SYSTEM_ROUTE(R) \
((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)

+#define RIB_KERNEL_ROUTE(R) \
+ ((R)->type == ZEBRA_ROUTE_KERNEL)
+
/* This function verifies reachability of one given nexthop, which can be
* numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored
* in nexthop->flags field. If the 4th parameter, 'set', is non-zero,
@@ -1128,6 +1131,10 @@ rib_process (struct route_node *rn)
redistribute_delete (&rn->p, fib);
if (! RIB_SYSTEM_ROUTE (fib))
rib_uninstall_kernel (rn, fib);
+#ifdef GNU_LINUX
+ else if(RIB_KERNEL_ROUTE (fib) &&
!if_is_up(if_lookup_by_index(fib->nexthop->ifindex)))
+ del=fib;
+#endif
UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);

/* Set real nexthop. */
--

2011/10/26 Greg Troxel <gdt [at] ir>:
>
> But there still remains the problem when interface is manually brought
> down. Then all static routes, ipv4 and ipv6, are deleted. There are no
> RTM_DELROUTE messages.
>
> Do you think that deleteing static routes from zebra's fib, if
> interface is down would be proper solution?
>
> No, I think the kernel should be fixed to send deletes for the routes it
> is removing as the interface is brought down (if it's going to delete
> such routes).
>
>
> Can you explain how your patch doesn't break the other N operating
> systems that don't automatically and silently delete routes?
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev

Quagga dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.