From f5d2ec4c4ee401eef68e603c90527d70c505736a Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Tue, 14 May 2024 03:17:46 +0530 Subject: [PATCH] fixup! fixup! feat: Make `net_(tcp|udp)` read limit configurable Signed-off-by: Pranshu Srivastava --- utils.go => internal/util/ptr.go | 6 +++--- net_ip_socket.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) rename utils.go => internal/util/ptr.go (87%) diff --git a/utils.go b/internal/util/ptr.go similarity index 87% rename from utils.go rename to internal/util/ptr.go index c56c9415..66372acb 100644 --- a/utils.go +++ b/internal/util/ptr.go @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package procfs +package util -// To returns a pointer to the given value. -func ptrTo[T any](v T) *T { +// PtrTo returns a pointer to the given value. +func PtrTo[T any](v T) *T { return &v } diff --git a/net_ip_socket.go b/net_ip_socket.go index 9f32ff4f..66c2dfbf 100644 --- a/net_ip_socket.go +++ b/net_ip_socket.go @@ -17,6 +17,7 @@ import ( "bufio" "encoding/hex" "fmt" + "github.com/prometheus/procfs/internal/util" "io" "net" "os" @@ -31,7 +32,7 @@ var ( // In theory, the number of available sockets is 65535 (2^16 - 1) per IP. // With e.g. 150 Byte per line and the maximum number of 65535, // the reader needs to handle 150 Byte * 65535 =~ 10 MB for a single IP. - defaultReadLimit = ptrTo(4294967296) // Byte -> 4 GiB + defaultReadLimit = util.PtrTo(4294967296) // Byte -> 4 GiB ) // This contains generic data structures for both udp and tcp sockets.