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

Method NewRoute

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

NewRoute implements inet.Stack.NewRoute.

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

Source from the content-addressed store, hash-verified

1073
1074// NewRoute implements inet.Stack.NewRoute.
1075func (s *Stack) NewRoute(ctx context.Context, msg *nlmsg.Message) *syserr.Error {
1076 localRoute, err := s.localRoute(msg)
1077 if err != nil {
1078 return err
1079 }
1080 found := false
1081 for _, rt := range s.Stack.GetRouteTable() {
1082 if localRoute.Equal(rt) {
1083 found = true
1084 break
1085 }
1086 }
1087 flags := msg.Header().Flags
1088 switch {
1089 case !found && flags&linux.NLM_F_CREATE == linux.NLM_F_CREATE:
1090 s.Stack.AddRoute(localRoute)
1091 case found && flags&linux.NLM_F_REPLACE != linux.NLM_F_REPLACE:
1092 return syserr.ErrExists
1093 }
1094 if flags&linux.NLM_F_REPLACE == linux.NLM_F_REPLACE {
1095 s.Stack.ReplaceRoute(localRoute)
1096 }
1097 return nil
1098}
1099
1100// IPTables returns the stack's iptables.
1101func (s *Stack) IPTables() (*stack.IPTables, error) {

Callers

nothing calls this directly

Calls 6

localRouteMethod · 0.95
GetRouteTableMethod · 0.80
AddRouteMethod · 0.80
ReplaceRouteMethod · 0.80
EqualMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected