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

Method RouteTable

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

RouteTable implements inet.Stack.RouteTable.

()

Source from the content-addressed store, hash-verified

912
913// RouteTable implements inet.Stack.RouteTable.
914func (s *Stack) RouteTable() []inet.Route {
915 var routeTable []inet.Route
916
917 for _, rt := range s.Stack.GetRouteTable() {
918 var family uint8
919 switch rt.Destination.ID().BitLen() {
920 case header.IPv4AddressSizeBits:
921 family = linux.AF_INET
922 case header.IPv6AddressSizeBits:
923 family = linux.AF_INET6
924 default:
925 log.Warningf("Unknown network protocol in route %+v", rt)
926 continue
927 }
928
929 dstAddr := rt.Destination.ID()
930 routeTable = append(routeTable, inet.Route{
931 Family: family,
932 DstLen: uint8(rt.Destination.Prefix()), // The CIDR prefix for the destination.
933
934 // Always return unspecified protocol since we have no notion of
935 // protocol for routes.
936 Protocol: linux.RTPROT_UNSPEC,
937 // Set statically to LINK scope for now.
938 //
939 // TODO(gvisor.dev/issue/595): Set scope for routes.
940 Scope: linux.RT_SCOPE_LINK,
941 Type: linux.RTN_UNICAST,
942
943 DstAddr: dstAddr.AsSlice(),
944 OutputInterface: int32(rt.NIC),
945 GatewayAddr: rt.Gateway.AsSlice(),
946 })
947 }
948
949 return routeTable
950}
951
952// localRoute constructs a local route from the netlink message.
953func (s *Stack) localRoute(msg *nlmsg.Message) (tcpip.Route, *syserr.Error) {

Callers

nothing calls this directly

Calls 6

WarningfFunction · 0.92
GetRouteTableMethod · 0.80
IDMethod · 0.65
BitLenMethod · 0.45
PrefixMethod · 0.45
AsSliceMethod · 0.45

Tested by

no test coverage detected