RemoveRoute implements inte.Stack.RemoveRoute.
(ctx context.Context, msg *nlmsg.Message)
| 1051 | |
| 1052 | // RemoveRoute implements inte.Stack.RemoveRoute. |
| 1053 | func (s *Stack) RemoveRoute(ctx context.Context, msg *nlmsg.Message) *syserr.Error { |
| 1054 | localRoute, err := s.localRoute(msg) |
| 1055 | if err != nil { |
| 1056 | return err |
| 1057 | } |
| 1058 | if removed := s.Stack.RemoveRoutes(func(rt tcpip.Route) bool { |
| 1059 | // Both gateway and NIC are compared with existing routes |
| 1060 | // only when they are present in the netlink message. |
| 1061 | if localRoute.Gateway.Len() > 0 && !localRoute.Gateway.Equal(rt.Gateway) { |
| 1062 | return false |
| 1063 | } |
| 1064 | if localRoute.NIC > 0 && localRoute.NIC != rt.NIC { |
| 1065 | return false |
| 1066 | } |
| 1067 | return rt.Destination.Equal(localRoute.Destination) |
| 1068 | }); removed == 0 { |
| 1069 | return syserr.ErrNoProcess |
| 1070 | } |
| 1071 | return nil |
| 1072 | } |
| 1073 | |
| 1074 | // NewRoute implements inet.Stack.NewRoute. |
| 1075 | func (s *Stack) NewRoute(ctx context.Context, msg *nlmsg.Message) *syserr.Error { |
nothing calls this directly
no test coverage detected