Merge pull request #152 from squat/check_netlink_events
pkg/route: correct route error check
This commit is contained in:
commit
e843262064
@ -108,14 +108,14 @@ func (t *Table) Run(stop <-chan struct{}) (<-chan error, error) {
|
|||||||
switch e.Type {
|
switch e.Type {
|
||||||
// Watch for deleted routes to reconcile this table's routes.
|
// Watch for deleted routes to reconcile this table's routes.
|
||||||
case unix.RTM_DELROUTE:
|
case unix.RTM_DELROUTE:
|
||||||
|
// Filter out invalid routes.
|
||||||
|
if e.Route.Dst == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
for k := range t.rs {
|
for k := range t.rs {
|
||||||
switch r := t.rs[k].(type) {
|
switch r := t.rs[k].(type) {
|
||||||
case *netlink.Route:
|
case *netlink.Route:
|
||||||
// Filter out invalid routes.
|
|
||||||
if r == nil || r.Dst == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// If any deleted route's destination matches a destination
|
// If any deleted route's destination matches a destination
|
||||||
// in the table, reset the corresponding route just in case.
|
// in the table, reset the corresponding route just in case.
|
||||||
if r.Dst.IP.Equal(e.Route.Dst.IP) && r.Dst.Mask.String() == e.Route.Dst.Mask.String() {
|
if r.Dst.IP.Equal(e.Route.Dst.IP) && r.Dst.Mask.String() == e.Route.Dst.Mask.String() {
|
||||||
|
Loading…
Reference in New Issue
Block a user