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

Possibly inadvertent script in LDP/LDP/guide/docbook/linux-ip/scripts/copy-routing-table.sh #91

Open
huangy7 opened this issue Oct 11, 2019 · 1 comment

Comments

@huangy7
Copy link

huangy7 commented Oct 11, 2019

# - - - - - - - - - - -
  copy_routing_table () {
# - - - - - - - - - - -
#
# -- accepts one paramater:
#
#    $1:  table identifier for the routing table to create
#
  test "$#" -lt "1"     && return
  DTABLE=$1

  test "$#" -gt "1"     && STABLE="$2"
  test "$STABLE" = ""   && STABLE="main"

  ip route flush table $DTABLE
  ip route show table $STABLE | grep -Ev '^default' \
    | while read ROUTE ; do
      ip route add table $DTABLE $ROUTE
  done

}

It will not work when an equivalent route exists in the routing table, For example:

[root@k8s-master topo_build]# ip route show
1.1.1.1 proto 188 metric 20 
	nexthop via 10.0.0.2 dev tun1 weight 1 
	nexthop via 10.0.2.2 dev tun3 weight 1 
2.0.0.2 proto 188 metric 20 
	nexthop via 10.0.1.2 dev tun2 weight 1 
	nexthop via 10.0.3.2 dev tun4 weight 1 

it will not work when we take routing in this way, It splits a route that occupies three rows into three routes...

[root@k8s-master topo_build]# ip route show | while read ROUTE; do echo [${i}]  $ROUTE; let i++; done
[] 1.1.1.1 proto 188 metric 20
[1] nexthop via 10.0.0.2 dev tun1 weight 1
[2] nexthop via 10.0.2.2 dev tun3 weight 1
[3] 2.0.0.2 proto 188 metric 20
[4] nexthop via 10.0.1.2 dev tun2 weight 1
[5] nexthop via 10.0.3.2 dev tun4 weight 1
@huangy7
Copy link
Author

huangy7 commented Oct 11, 2019

But I haven't thought of a solution yet.

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

No branches or pull requests

1 participant