.free = NULL,
};
+static bool L3_verify_initial_line(const char *line)
+{
+ /* At least we expect two white spaces. */
+ if (strncmp (line, " ", 2) != 0)
+ return false;
+ line += 2;
+
+ /* Skip white spaces. */
+ while (*line == ' ')
+ line++;
+
+ return (strncmp(line, "sl", 2) == 0);
+}
+
#define TCP_LINE_LEN 256
static void load_xinfo_from_proc_inet_L3(ino_t netns_inode, const char *proc_file,
- bool (*verify_initial_line)(const char *),
struct sock_xinfo_class *class)
{
char line[TCP_LINE_LEN];
if (fgets(line, sizeof(line), tcp_fp) == NULL)
goto out;
- if (!verify_initial_line(line))
+ if (!L3_verify_initial_line(line))
/* Unexpected line */
goto out;
fclose(tcp_fp);
}
-static bool tcp_verify_initial_line(const char *line)
-{
- /* At least we expect two white spaces. */
- if (strncmp (line, " ", 2) != 0)
- return false;
- line += 2;
-
- /* Skip white spaces. */
- while (*line == ' ')
- line++;
-
- return (strncmp(line, "sl", 2) == 0);
-}
-
-
static void load_xinfo_from_proc_tcp(ino_t netns_inode)
{
load_xinfo_from_proc_inet_L3(netns_inode,
- "/proc/net/tcp", tcp_verify_initial_line,
+ "/proc/net/tcp",
&tcp_xinfo_class);
}
{
load_xinfo_from_proc_inet_L3(netns_inode,
"/proc/net/udp",
- tcp_verify_initial_line,
&udp_xinfo_class);
}