MCPcopy Index your code
hub / github.com/google/gvisor / RemoveRoute

Method RemoveRoute

pkg/sentry/socket/netstack/stack.go:1053–1072  ·  view source on GitHub ↗

RemoveRoute implements inte.Stack.RemoveRoute.

(ctx context.Context, msg *nlmsg.Message)

Source from the content-addressed store, hash-verified

1051
1052// RemoveRoute implements inte.Stack.RemoveRoute.
1053func (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.
1075func (s *Stack) NewRoute(ctx context.Context, msg *nlmsg.Message) *syserr.Error {

Callers

nothing calls this directly

Calls 4

localRouteMethod · 0.95
RemoveRoutesMethod · 0.80
LenMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected