NetProtocols reads stats from /proc/net/protocols and returns a map of PortocolStatLine entries. As of this writing no official Linux Documentation exists, however the source is fairly self-explanatory and the format seems stable since its introduction in 2.6.12-rc2 Linux 2.6.12-rc2 - https://elixir
()
| 71 | // Linux 2.6.12-rc2 - https://elixir.bootlin.com/linux/v2.6.12-rc2/source/net/core/sock.c#L1452 |
| 72 | // Linux 5.10 - https://elixir.bootlin.com/linux/v5.10.4/source/net/core/sock.c#L3586 |
| 73 | func (fs FS) NetProtocols() (NetProtocolStats, error) { |
| 74 | data, err := util.ReadFileNoStat(fs.proc.Path("net/protocols")) |
| 75 | if err != nil { |
| 76 | return NetProtocolStats{}, err |
| 77 | } |
| 78 | return parseNetProtocols(bufio.NewScanner(bytes.NewReader(data))) |
| 79 | } |
| 80 | |
| 81 | func parseNetProtocols(s *bufio.Scanner) (NetProtocolStats, error) { |
| 82 | nps := NetProtocolStats{} |