aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
Diffstat (limited to 'net/core')
-rw-r--r--net/core/sock.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index c14ce0198d25..252d21a1bb04 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1851,46 +1851,15 @@ void proto_unregister(struct proto *prot)
1851EXPORT_SYMBOL(proto_unregister); 1851EXPORT_SYMBOL(proto_unregister);
1852 1852
1853#ifdef CONFIG_PROC_FS 1853#ifdef CONFIG_PROC_FS
1854static inline struct proto *__proto_head(void)
1855{
1856 return list_entry(proto_list.next, struct proto, node);
1857}
1858
1859static inline struct proto *proto_head(void)
1860{
1861 return list_empty(&proto_list) ? NULL : __proto_head();
1862}
1863
1864static inline struct proto *proto_next(struct proto *proto)
1865{
1866 return proto->node.next == &proto_list ? NULL :
1867 list_entry(proto->node.next, struct proto, node);
1868}
1869
1870static inline struct proto *proto_get_idx(loff_t pos)
1871{
1872 struct proto *proto;
1873 loff_t i = 0;
1874
1875 list_for_each_entry(proto, &proto_list, node)
1876 if (i++ == pos)
1877 goto out;
1878
1879 proto = NULL;
1880out:
1881 return proto;
1882}
1883
1884static void *proto_seq_start(struct seq_file *seq, loff_t *pos) 1854static void *proto_seq_start(struct seq_file *seq, loff_t *pos)
1885{ 1855{
1886 read_lock(&proto_list_lock); 1856 read_lock(&proto_list_lock);
1887 return *pos ? proto_get_idx(*pos - 1) : SEQ_START_TOKEN; 1857 return seq_list_start_head(&proto_list, *pos);
1888} 1858}
1889 1859
1890static void *proto_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1860static void *proto_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1891{ 1861{
1892 ++*pos; 1862 return seq_list_next(v, &proto_list, pos);
1893 return v == SEQ_START_TOKEN ? proto_head() : proto_next(v);
1894} 1863}
1895 1864
1896static void proto_seq_stop(struct seq_file *seq, void *v) 1865static void proto_seq_stop(struct seq_file *seq, void *v)
@@ -1938,7 +1907,7 @@ static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
1938 1907
1939static int proto_seq_show(struct seq_file *seq, void *v) 1908static int proto_seq_show(struct seq_file *seq, void *v)
1940{ 1909{
1941 if (v == SEQ_START_TOKEN) 1910 if (v == &proto_list)
1942 seq_printf(seq, "%-9s %-4s %-8s %-6s %-5s %-7s %-4s %-10s %s", 1911 seq_printf(seq, "%-9s %-4s %-8s %-6s %-5s %-7s %-4s %-10s %s",
1943 "protocol", 1912 "protocol",
1944 "size", 1913 "size",
@@ -1950,7 +1919,7 @@ static int proto_seq_show(struct seq_file *seq, void *v)
1950 "module", 1919 "module",
1951 "cl co di ac io in de sh ss gs se re sp bi br ha uh gp em\n"); 1920 "cl co di ac io in de sh ss gs se re sp bi br ha uh gp em\n");
1952 else 1921 else
1953 proto_seq_printf(seq, v); 1922 proto_seq_printf(seq, list_entry(v, struct proto, node));
1954 return 0; 1923 return 0;
1955} 1924}
1956 1925