github.com/ttpreport/gvisor-ligolo@v0.0.0-20240123134145-a858404967ba/pkg/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 "github.com/ttpreport/gvisor-ligolo/pkg/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 droppedConfirmationForNoninitiatedNeighbor tcpip.MultiCounterStat 45 droppedInvalidLinkAddressConfirmations tcpip.MultiCounterStat 46 } 47 48 func (m *multiCounterNICNeighborStats) init(a, b *tcpip.NICNeighborStats) { 49 m.unreachableEntryLookups.Init(a.UnreachableEntryLookups, b.UnreachableEntryLookups) 50 m.droppedConfirmationForNoninitiatedNeighbor.Init(a.DroppedConfirmationForNoninitiatedNeighbor, b.DroppedConfirmationForNoninitiatedNeighbor) 51 m.droppedInvalidLinkAddressConfirmations.Init(a.DroppedInvalidLinkAddressConfirmations, b.DroppedInvalidLinkAddressConfirmations) 52 } 53 54 // LINT.ThenChange(../tcpip.go:NICNeighborStats) 55 56 // LINT.IfChange(multiCounterNICStats) 57 58 type multiCounterNICStats struct { 59 unknownL3ProtocolRcvdPacketCounts tcpip.MultiIntegralStatCounterMap 60 unknownL4ProtocolRcvdPacketCounts tcpip.MultiIntegralStatCounterMap 61 malformedL4RcvdPackets tcpip.MultiCounterStat 62 tx multiCounterNICPacketStats 63 txPacketsDroppedNoBufferSpace tcpip.MultiCounterStat 64 rx multiCounterNICPacketStats 65 disabledRx multiCounterNICPacketStats 66 neighbor multiCounterNICNeighborStats 67 } 68 69 func (m *multiCounterNICStats) init(a, b *tcpip.NICStats) { 70 m.unknownL3ProtocolRcvdPacketCounts.Init(a.UnknownL3ProtocolRcvdPacketCounts, b.UnknownL3ProtocolRcvdPacketCounts) 71 m.unknownL4ProtocolRcvdPacketCounts.Init(a.UnknownL4ProtocolRcvdPacketCounts, b.UnknownL4ProtocolRcvdPacketCounts) 72 m.malformedL4RcvdPackets.Init(a.MalformedL4RcvdPackets, b.MalformedL4RcvdPackets) 73 m.tx.init(&a.Tx, &b.Tx) 74 m.txPacketsDroppedNoBufferSpace.Init(a.TxPacketsDroppedNoBufferSpace, b.TxPacketsDroppedNoBufferSpace) 75 m.rx.init(&a.Rx, &b.Rx) 76 m.disabledRx.init(&a.DisabledRx, &b.DisabledRx) 77 m.neighbor.init(&a.Neighbor, &b.Neighbor) 78 } 79 80 // LINT.ThenChange(../tcpip.go:NICStats)