Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static stuff #1819

Merged
merged 2 commits into from
Mar 14, 2018
Merged

Static stuff #1819

merged 2 commits into from
Mar 14, 2018

Conversation

donaldsharp
Copy link
Member

It is possible to cause zebra to crash when you have static routes configured under a non-fully initialized vrf. These commits fix this issue.

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2725/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


CLANG Static Analyzer Summary

  • Github Pull Request 1819, comparing to Git base SHA a8e31fc

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2725/artifact/shared/static_analysis/index.html

@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 4, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/1819 908e1b2
Date 03/03/2018
Start 18:59:09
Finish 19:22:14
Run-Time 23:05
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-03-03-18:59:09.txt
Log autoscript-2018-03-03-18:59:50.log.bz2

For details, please contact louberger

return CMD_SUCCESS;
}

assert(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen a neat assert variant used elsewhere in the codebase that provides some debugging info, it looks like this:
assert(!"my error message")
It's helped me in the past with debugging. Alternatively a comment around this area might be good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@pguibert6WIND pguibert6WIND left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 remarks:

  • what about cases where routes are installed but fail due to other error ( no mpls, bad mpls value, bad format)
  • some errors should be displayed upon vrf on

shr->dest_str, shr->mask_str, shr->src_str,
shr->gate_str, shr->ifname, shr->flag_str, shr->tag_str,
shr->distance_str, shr->label_str);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting the returned value of zebra_statis_route_leak could permit to know exactly if an entry has been installed or not ( case mpls is not present in kernel)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not much to do with it other than to notice the rejection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we remove the static entry from the list ?

vty_out(vty, "%% Nexthop interface cannot be Null0, reject or blackhole\n");
if (vty)
vty_out(vty,
"%% Nexthop interface cannot be Null0, reject or blackhole\n");
return CMD_WARNING_CONFIG_FAILED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that event should be logged into a zlog_xxx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

vty_out(vty,
"%% Cannot use reserved label(s) (%d-%d)\n",
MPLS_LABEL_RESERVED_MIN,
MPLS_LABEL_RESERVED_MAX);
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that event should be logged into a zlog_xxx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dibe

"%% MPLS not turned on in kernel, ignoring command\n");
if (vty)
vty_out(vty,
"%% MPLS not turned on in kernel, ignoring command\n");
return CMD_WARNING_CONFIG_FAILED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that event should be logged into a zlog_xxx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

When you have individual 'ip route..' commands
under a VRF allow them to be displayed properly

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
When zebra is being configed we allow for static routes
to be entered.  This presents a problem for when a vrf
is cli configed but not kernel configed yet.

Modify zebra to notice that when a static route is
entered and either the nexthop vrf or the vrf
is not fully configed, to save that config to the
side.

When vrf's become active( kernel configed ) parse
through the list of saved to the side static routes
and determine if any of them can be installed.

Additionally modify the cli to output the saved
to the side cli, so that we can properly handle
a wr mem.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 7, 2018

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/1819 4060008
Date 03/07/2018
Start 14:35:21
Finish 14:58:07
Run-Time 22:46
Total 1816
Pass 1816
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2018-03-07-14:35:21.txt
Log autoscript-2018-03-07-14:35:57.log.bz2

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2793/

This is a comment from an EXPERIMENTAL automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.


Warnings Generated during build:

Checkout code: Successful with additional warnings:

Report for zebra_vty.c
===============================================
< WARNING: line over 80 characters
< #252: FILE: /tmp/f1/zebra_vty.c:252:
< +		assert(!"We should not have found a duplicate and not remove it");
< 

CLANG Static Analyzer Summary

  • Github Pull Request 1819, comparing to Git base SHA 54085ea

No Changes in Static Analysis warnings compared to base

19 Static Analyzer issues remaining.

See details at
https://ci1.netdef.org/browse/FRR-FRRPULLREQ-2793/artifact/shared/static_analysis/index.html

@rwestphal
Copy link
Member

I wonder if we couldn't solve this problem in a simpler way.

We used to have a similar problem with static routes pointing to non-existing interfaces. This was fixed by this commit: c3c04063

In short, the fix was to store nexthop interfaces using their names and not their ifindexes. Then, pior to calling static_install_route(), we'd try to find the corresponding ifindex using if_lookup_by_name(ifname, ...). If the interface wasn't found, then the route installation would be postponed until the interface was added to the system (if_add_update()).

I think we could try to do something similar here. We could change the static_route structure to store VRFs by their name and not by their index. Then, whenever a new VRF is detected in the system (zebra_vrf_enable()), loop through all static routes from all VRFs and detect which ones can now be installed with static_install_route() (both the VRF and nexthop-VRF must be available). What do you think about this?

@rwestphal
Copy link
Member

Also, this diff doesn't solve the problem completely:

debian(config)# vrf RED
debian(config-vrf)# ip route 50.0.0.0/8 eth80 nexthop-vrf BLUE
% nexthop vrf BLUE is not defined
debian(config)# exit
debian(config)# ip route 60.0.0.0/8 eth50 vrf BLACK
% vrf BLACK is not defined

If we store VRF using their names then the commands above will work even if the VRFs don't exist.

@rwestphal rwestphal mentioned this pull request Mar 13, 2018
Copy link
Member

@pguibert6WIND pguibert6WIND left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-I don't know if Renatos idea could be applied to this.
I would tend to think this change could be done.
-like that, my comment on "removing the static entry from the list " could be ignored, since all entries may be valid but will really be taken into account if underlying ( lets start with vrf) are available.

shr->dest_str, shr->mask_str, shr->src_str,
shr->gate_str, shr->ifname, shr->flag_str, shr->tag_str,
shr->distance_str, shr->label_str);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we remove the static entry from the list ?

vty_out(vty, "%% Nexthop interface cannot be Null0, reject or blackhole\n");
if (vty)
vty_out(vty,
"%% Nexthop interface cannot be Null0, reject or blackhole\n");
return CMD_WARNING_CONFIG_FAILED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@pguibert6WIND
Copy link
Member

I agree to keep the changes as they are
and track the continuation on #1819

@rwestphal
Copy link
Member

rwestphal commented Mar 14, 2018

In the light of #1887, I think these changes can get in and we should take the issue of non-existing VRFs into consideration when refactoring the handling of static routes in zebra. Will merge now.

@rwestphal rwestphal merged commit f22ab4c into FRRouting:master Mar 14, 2018
@donaldsharp donaldsharp deleted the static_stuff branch March 24, 2018 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants