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

Method newInterface

pkg/sentry/socket/netstack/stack.go:547–580  ·  view source on GitHub ↗
(ctx context.Context, msg *nlmsg.Message, linkAttrs map[uint16]nlmsg.BytesView)

Source from the content-addressed store, hash-verified

545}
546
547func (s *Stack) newInterface(ctx context.Context, msg *nlmsg.Message, linkAttrs map[uint16]nlmsg.BytesView) *syserr.Error {
548 var (
549 linkInfoAttrs map[uint16]nlmsg.BytesView
550 kind string
551 )
552
553 if v, ok := linkAttrs[linux.IFLA_LINKINFO]; ok {
554 linkInfoAttrs, ok = nlmsg.AttrsView(v).Parse()
555 if !ok {
556 return syserr.ErrInvalidArgument
557 }
558
559 for attr := range linkInfoAttrs {
560 value := linkInfoAttrs[attr]
561 switch attr {
562 case linux.IFLA_INFO_KIND:
563 kind = value.String()
564 case linux.IFLA_INFO_DATA:
565 default:
566 ctx.Warningf("unexpected link info attribute: %x", attr)
567 return syserr.ErrNotSupported
568 }
569 }
570 }
571 switch kind {
572 case "":
573 return syserr.ErrInvalidArgument
574 case "bridge":
575 return s.newBridge(ctx, linkAttrs, linkInfoAttrs)
576 case "veth":
577 return s.newVeth(ctx, linkAttrs, linkInfoAttrs)
578 }
579 return syserr.ErrNotSupported
580}
581
582// InterfaceAddrs implements inet.Stack.InterfaceAddrs.
583func (s *Stack) InterfaceAddrs() map[int32][]inet.InterfaceAddr {

Callers 1

SetInterfaceMethod · 0.95

Calls 6

newBridgeMethod · 0.95
newVethMethod · 0.95
AttrsViewTypeAlias · 0.92
ParseMethod · 0.65
StringMethod · 0.65
WarningfMethod · 0.65

Tested by

no test coverage detected