mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Changes to support netstack save restore.
- Added a new Stats() method in inet.Stack to get the saved stats during restore. - Mark stack.nic, tcpip.Route and stack.addressState structs as "nosave". These fields should not be saved because the IP addresses and routes can change during restore and new configuration of routes and IP addresses will be extracted from the restore spec and initialized in the saved stack. - Changes in Restore() method in icmp, udp, tcp, packet and raw endpoint files to support save restore of these endpoints. These changes are flag guarded by the TESTONLY-save-restore-netstack flag. PiperOrigin-RevId: 707639274
This commit is contained in:
committed by
gVisor bot
parent
44562d85cf
commit
a3e5887415
@@ -592,6 +592,7 @@ func (s *Stack) SetTCPRecovery(recovery inet.TCPLossRecovery) error {
|
||||
|
||||
// Statistics implements inet.Stack.Statistics.
|
||||
func (s *Stack) Statistics(stat any, arg string) error {
|
||||
netStats := s.Stats()
|
||||
switch stats := stat.(type) {
|
||||
case *inet.StatDev:
|
||||
for _, ni := range s.Stack.NICInfo() {
|
||||
@@ -622,7 +623,7 @@ func (s *Stack) Statistics(stat any, arg string) error {
|
||||
break
|
||||
}
|
||||
case *inet.StatSNMPIP:
|
||||
ip := Metrics.IP
|
||||
ip := netStats.IP
|
||||
// TODO(gvisor.dev/issue/969) Support stubbed stats.
|
||||
*stats = inet.StatSNMPIP{
|
||||
0, // Ip/Forwarding.
|
||||
@@ -646,8 +647,8 @@ func (s *Stack) Statistics(stat any, arg string) error {
|
||||
0, // Support Ip/FragCreates.
|
||||
}
|
||||
case *inet.StatSNMPICMP:
|
||||
in := Metrics.ICMP.V4.PacketsReceived.ICMPv4PacketStats
|
||||
out := Metrics.ICMP.V4.PacketsSent.ICMPv4PacketStats
|
||||
in := netStats.ICMP.V4.PacketsReceived.ICMPv4PacketStats
|
||||
out := netStats.ICMP.V4.PacketsSent.ICMPv4PacketStats
|
||||
// TODO(gvisor.dev/issue/969) Support stubbed stats.
|
||||
*stats = inet.StatSNMPICMP{
|
||||
0, // Icmp/InMsgs.
|
||||
@@ -679,7 +680,7 @@ func (s *Stack) Statistics(stat any, arg string) error {
|
||||
out.InfoReply.Value(), // OutAddrMaskReps.
|
||||
}
|
||||
case *inet.StatSNMPTCP:
|
||||
tcp := Metrics.TCP
|
||||
tcp := netStats.TCP
|
||||
// RFC 2012 (updates 1213): SNMPv2-MIB-TCP.
|
||||
*stats = inet.StatSNMPTCP{
|
||||
1, // RtoAlgorithm.
|
||||
@@ -699,7 +700,7 @@ func (s *Stack) Statistics(stat any, arg string) error {
|
||||
tcp.ChecksumErrors.Value(), // InCsumErrors.
|
||||
}
|
||||
case *inet.StatSNMPUDP:
|
||||
udp := Metrics.UDP
|
||||
udp := netStats.UDP
|
||||
// TODO(gvisor.dev/issue/969) Support stubbed stats.
|
||||
*stats = inet.StatSNMPUDP{
|
||||
udp.PacketsReceived.Value(), // InDatagrams.
|
||||
@@ -717,6 +718,11 @@ func (s *Stack) Statistics(stat any, arg string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stats implements inet.Stack.Stats.
|
||||
func (s *Stack) Stats() tcpip.Stats {
|
||||
return s.Stack.Stats()
|
||||
}
|
||||
|
||||
// RouteTable implements inet.Stack.RouteTable.
|
||||
func (s *Stack) RouteTable() []inet.Route {
|
||||
var routeTable []inet.Route
|
||||
|
||||
Reference in New Issue
Block a user