inet.af/netstack@v0.0.0-20220214151720-7585b01ddccf/tcpip/stack/nic_stats.go (about) 1 // Copyright 2021 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package stack 16 17 import ( 18 "inet.af/netstack/tcpip" 19 ) 20 21 type sharedStats struct { 22 local tcpip.NICStats 23 multiCounterNICStats 24 } 25 26 // LINT.IfChange(multiCounterNICPacketStats) 27 28 type multiCounterNICPacketStats struct { 29 packets tcpip.MultiCounterStat 30 bytes tcpip.MultiCounterStat 31 } 32 33 func (m *multiCounterNICPacketStats) init(a, b *tcpip.NICPacketStats) { 34 m.packets.Init(a.Packets, b.Packets) 35 m.bytes.Init(a.Bytes, b.Bytes) 36 } 37 38 // LINT.ThenChange(../tcpip.go:NICPacketStats) 39 40 // LINT.IfChange(multiCounterNICNeighborStats) 41 42 type multiCounterNICNeighborStats struct { 43 unreachableEntryLookups tcpip.MultiCounterStat 44 } 45 46 func (m *multiCounterNICNeighborStats) init(a, b *tcpip.NICNeighborStats) { 47 m.unreachableEntryLookups.Init(a.UnreachableEntryLookups, b.UnreachableEntryLookups) 48 } 49 50 // LINT.ThenChange(../tcpip.go:NICNeighborStats) 51 52 // LINT.IfChange(multiCounterNICStats) 53 54 type multiCounterNICStats struct { 55 unknownL3ProtocolRcvdPacketCounts tcpip.MultiIntegralStatCounterMap 56 unknownL4ProtocolRcvdPacketCounts tcpip.MultiIntegralStatCounterMap 57 malformedL4RcvdPackets tcpip.MultiCounterStat 58 tx multiCounterNICPacketStats 59 rx multiCounterNICPacketStats 60 disabledRx multiCounterNICPacketStats 61 neighbor multiCounterNICNeighborStats 62 } 63 64 func (m *multiCounterNICStats) init(a, b *tcpip.NICStats) { 65 m.unknownL3ProtocolRcvdPacketCounts.Init(a.UnknownL3ProtocolRcvdPacketCounts, b.UnknownL3ProtocolRcvdPacketCounts) 66 m.unknownL4ProtocolRcvdPacketCounts.Init(a.UnknownL4ProtocolRcvdPacketCounts, b.UnknownL4ProtocolRcvdPacketCounts) 67 m.malformedL4RcvdPackets.Init(a.MalformedL4RcvdPackets, b.MalformedL4RcvdPackets) 68 m.tx.init(&a.Tx, &b.Tx) 69 m.rx.init(&a.Rx, &b.Rx) 70 m.disabledRx.init(&a.DisabledRx, &b.DisabledRx) 71 m.neighbor.init(&a.Neighbor, &b.Neighbor) 72 } 73 74 // LINT.ThenChange(../tcpip.go:NICStats)