aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2013-11-14 17:31:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 19:32:20 -0500
commit652586df95e5d76b37d07a11839126dcfede1621 (patch)
treee3a668265cade256302830ea3ff8b3699ab2977e /net/ipv4
parent839cc2a94cc3665bafe32203c2f095f4dd470a80 (diff)
seq_file: remove "%n" usage from seq_file users
All seq_printf() users are using "%n" for calculating padding size, convert them to use seq_setwidth() / seq_pad() pair. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Joe Perches <joe@perches.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/fib_trie.c13
-rw-r--r--net/ipv4/ping.c15
-rw-r--r--net/ipv4/tcp_ipv4.c33
-rw-r--r--net/ipv4/udp.c15
4 files changed, 36 insertions, 40 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index ec9a9ef4ce50..5afeb5aa4c7c 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2523,16 +2523,17 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2523 list_for_each_entry_rcu(fa, &li->falh, fa_list) { 2523 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2524 const struct fib_info *fi = fa->fa_info; 2524 const struct fib_info *fi = fa->fa_info;
2525 unsigned int flags = fib_flag_trans(fa->fa_type, mask, fi); 2525 unsigned int flags = fib_flag_trans(fa->fa_type, mask, fi);
2526 int len;
2527 2526
2528 if (fa->fa_type == RTN_BROADCAST 2527 if (fa->fa_type == RTN_BROADCAST
2529 || fa->fa_type == RTN_MULTICAST) 2528 || fa->fa_type == RTN_MULTICAST)
2530 continue; 2529 continue;
2531 2530
2531 seq_setwidth(seq, 127);
2532
2532 if (fi) 2533 if (fi)
2533 seq_printf(seq, 2534 seq_printf(seq,
2534 "%s\t%08X\t%08X\t%04X\t%d\t%u\t" 2535 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
2535 "%d\t%08X\t%d\t%u\t%u%n", 2536 "%d\t%08X\t%d\t%u\t%u",
2536 fi->fib_dev ? fi->fib_dev->name : "*", 2537 fi->fib_dev ? fi->fib_dev->name : "*",
2537 prefix, 2538 prefix,
2538 fi->fib_nh->nh_gw, flags, 0, 0, 2539 fi->fib_nh->nh_gw, flags, 0, 0,
@@ -2541,15 +2542,15 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2541 (fi->fib_advmss ? 2542 (fi->fib_advmss ?
2542 fi->fib_advmss + 40 : 0), 2543 fi->fib_advmss + 40 : 0),
2543 fi->fib_window, 2544 fi->fib_window,
2544 fi->fib_rtt >> 3, &len); 2545 fi->fib_rtt >> 3);
2545 else 2546 else
2546 seq_printf(seq, 2547 seq_printf(seq,
2547 "*\t%08X\t%08X\t%04X\t%d\t%u\t" 2548 "*\t%08X\t%08X\t%04X\t%d\t%u\t"
2548 "%d\t%08X\t%d\t%u\t%u%n", 2549 "%d\t%08X\t%d\t%u\t%u",
2549 prefix, 0, flags, 0, 0, 0, 2550 prefix, 0, flags, 0, 0, 0,
2550 mask, 0, 0, 0, &len); 2551 mask, 0, 0, 0);
2551 2552
2552 seq_printf(seq, "%*s\n", 127 - len, ""); 2553 seq_pad(seq, '\n');
2553 } 2554 }
2554 } 2555 }
2555 2556
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 9afbdb19f4a2..cbc85f660d54 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1076,7 +1076,7 @@ void ping_seq_stop(struct seq_file *seq, void *v)
1076EXPORT_SYMBOL_GPL(ping_seq_stop); 1076EXPORT_SYMBOL_GPL(ping_seq_stop);
1077 1077
1078static void ping_v4_format_sock(struct sock *sp, struct seq_file *f, 1078static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1079 int bucket, int *len) 1079 int bucket)
1080{ 1080{
1081 struct inet_sock *inet = inet_sk(sp); 1081 struct inet_sock *inet = inet_sk(sp);
1082 __be32 dest = inet->inet_daddr; 1082 __be32 dest = inet->inet_daddr;
@@ -1085,7 +1085,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1085 __u16 srcp = ntohs(inet->inet_sport); 1085 __u16 srcp = ntohs(inet->inet_sport);
1086 1086
1087 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 1087 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
1088 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d%n", 1088 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d",
1089 bucket, src, srcp, dest, destp, sp->sk_state, 1089 bucket, src, srcp, dest, destp, sp->sk_state,
1090 sk_wmem_alloc_get(sp), 1090 sk_wmem_alloc_get(sp),
1091 sk_rmem_alloc_get(sp), 1091 sk_rmem_alloc_get(sp),
@@ -1093,23 +1093,22 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1093 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)), 1093 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
1094 0, sock_i_ino(sp), 1094 0, sock_i_ino(sp),
1095 atomic_read(&sp->sk_refcnt), sp, 1095 atomic_read(&sp->sk_refcnt), sp,
1096 atomic_read(&sp->sk_drops), len); 1096 atomic_read(&sp->sk_drops));
1097} 1097}
1098 1098
1099static int ping_v4_seq_show(struct seq_file *seq, void *v) 1099static int ping_v4_seq_show(struct seq_file *seq, void *v)
1100{ 1100{
1101 seq_setwidth(seq, 127);
1101 if (v == SEQ_START_TOKEN) 1102 if (v == SEQ_START_TOKEN)
1102 seq_printf(seq, "%-127s\n", 1103 seq_puts(seq, " sl local_address rem_address st tx_queue "
1103 " sl local_address rem_address st tx_queue "
1104 "rx_queue tr tm->when retrnsmt uid timeout " 1104 "rx_queue tr tm->when retrnsmt uid timeout "
1105 "inode ref pointer drops"); 1105 "inode ref pointer drops");
1106 else { 1106 else {
1107 struct ping_iter_state *state = seq->private; 1107 struct ping_iter_state *state = seq->private;
1108 int len;
1109 1108
1110 ping_v4_format_sock(v, seq, state->bucket, &len); 1109 ping_v4_format_sock(v, seq, state->bucket);
1111 seq_printf(seq, "%*s\n", 127 - len, "");
1112 } 1110 }
1111 seq_pad(seq, '\n');
1113 return 0; 1112 return 0;
1114} 1113}
1115 1114
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 14bba8a1c5a7..59a6f8b90cd9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2541,13 +2541,13 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo)
2541EXPORT_SYMBOL(tcp_proc_unregister); 2541EXPORT_SYMBOL(tcp_proc_unregister);
2542 2542
2543static void get_openreq4(const struct sock *sk, const struct request_sock *req, 2543static void get_openreq4(const struct sock *sk, const struct request_sock *req,
2544 struct seq_file *f, int i, kuid_t uid, int *len) 2544 struct seq_file *f, int i, kuid_t uid)
2545{ 2545{
2546 const struct inet_request_sock *ireq = inet_rsk(req); 2546 const struct inet_request_sock *ireq = inet_rsk(req);
2547 long delta = req->expires - jiffies; 2547 long delta = req->expires - jiffies;
2548 2548
2549 seq_printf(f, "%4d: %08X:%04X %08X:%04X" 2549 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
2550 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %pK%n", 2550 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %pK",
2551 i, 2551 i,
2552 ireq->ir_loc_addr, 2552 ireq->ir_loc_addr,
2553 ntohs(inet_sk(sk)->inet_sport), 2553 ntohs(inet_sk(sk)->inet_sport),
@@ -2562,11 +2562,10 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
2562 0, /* non standard timer */ 2562 0, /* non standard timer */
2563 0, /* open_requests have no inode */ 2563 0, /* open_requests have no inode */
2564 atomic_read(&sk->sk_refcnt), 2564 atomic_read(&sk->sk_refcnt),
2565 req, 2565 req);
2566 len);
2567} 2566}
2568 2567
2569static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) 2568static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
2570{ 2569{
2571 int timer_active; 2570 int timer_active;
2572 unsigned long timer_expires; 2571 unsigned long timer_expires;
@@ -2605,7 +2604,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2605 rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0); 2604 rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);
2606 2605
2607 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX " 2606 seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
2608 "%08X %5u %8d %lu %d %pK %lu %lu %u %u %d%n", 2607 "%08X %5u %8d %lu %d %pK %lu %lu %u %u %d",
2609 i, src, srcp, dest, destp, sk->sk_state, 2608 i, src, srcp, dest, destp, sk->sk_state,
2610 tp->write_seq - tp->snd_una, 2609 tp->write_seq - tp->snd_una,
2611 rx_queue, 2610 rx_queue,
@@ -2622,12 +2621,11 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2622 tp->snd_cwnd, 2621 tp->snd_cwnd,
2623 sk->sk_state == TCP_LISTEN ? 2622 sk->sk_state == TCP_LISTEN ?
2624 (fastopenq ? fastopenq->max_qlen : 0) : 2623 (fastopenq ? fastopenq->max_qlen : 0) :
2625 (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh), 2624 (tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh));
2626 len);
2627} 2625}
2628 2626
2629static void get_timewait4_sock(const struct inet_timewait_sock *tw, 2627static void get_timewait4_sock(const struct inet_timewait_sock *tw,
2630 struct seq_file *f, int i, int *len) 2628 struct seq_file *f, int i)
2631{ 2629{
2632 __be32 dest, src; 2630 __be32 dest, src;
2633 __u16 destp, srcp; 2631 __u16 destp, srcp;
@@ -2639,10 +2637,10 @@ static void get_timewait4_sock(const struct inet_timewait_sock *tw,
2639 srcp = ntohs(tw->tw_sport); 2637 srcp = ntohs(tw->tw_sport);
2640 2638
2641 seq_printf(f, "%4d: %08X:%04X %08X:%04X" 2639 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
2642 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK%n", 2640 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK",
2643 i, src, srcp, dest, destp, tw->tw_substate, 0, 0, 2641 i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
2644 3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0, 2642 3, jiffies_delta_to_clock_t(delta), 0, 0, 0, 0,
2645 atomic_read(&tw->tw_refcnt), tw, len); 2643 atomic_read(&tw->tw_refcnt), tw);
2646} 2644}
2647 2645
2648#define TMPSZ 150 2646#define TMPSZ 150
@@ -2651,11 +2649,10 @@ static int tcp4_seq_show(struct seq_file *seq, void *v)
2651{ 2649{
2652 struct tcp_iter_state *st; 2650 struct tcp_iter_state *st;
2653 struct sock *sk = v; 2651 struct sock *sk = v;
2654 int len;
2655 2652
2653 seq_setwidth(seq, TMPSZ - 1);
2656 if (v == SEQ_START_TOKEN) { 2654 if (v == SEQ_START_TOKEN) {
2657 seq_printf(seq, "%-*s\n", TMPSZ - 1, 2655 seq_puts(seq, " sl local_address rem_address st tx_queue "
2658 " sl local_address rem_address st tx_queue "
2659 "rx_queue tr tm->when retrnsmt uid timeout " 2656 "rx_queue tr tm->when retrnsmt uid timeout "
2660 "inode"); 2657 "inode");
2661 goto out; 2658 goto out;
@@ -2666,16 +2663,16 @@ static int tcp4_seq_show(struct seq_file *seq, void *v)
2666 case TCP_SEQ_STATE_LISTENING: 2663 case TCP_SEQ_STATE_LISTENING:
2667 case TCP_SEQ_STATE_ESTABLISHED: 2664 case TCP_SEQ_STATE_ESTABLISHED:
2668 if (sk->sk_state == TCP_TIME_WAIT) 2665 if (sk->sk_state == TCP_TIME_WAIT)
2669 get_timewait4_sock(v, seq, st->num, &len); 2666 get_timewait4_sock(v, seq, st->num);
2670 else 2667 else
2671 get_tcp4_sock(v, seq, st->num, &len); 2668 get_tcp4_sock(v, seq, st->num);
2672 break; 2669 break;
2673 case TCP_SEQ_STATE_OPENREQ: 2670 case TCP_SEQ_STATE_OPENREQ:
2674 get_openreq4(st->syn_wait_sk, v, seq, st->num, st->uid, &len); 2671 get_openreq4(st->syn_wait_sk, v, seq, st->num, st->uid);
2675 break; 2672 break;
2676 } 2673 }
2677 seq_printf(seq, "%*s\n", TMPSZ - 1 - len, "");
2678out: 2674out:
2675 seq_pad(seq, '\n');
2679 return 0; 2676 return 0;
2680} 2677}
2681 2678
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 89909dd730dd..de86e5bc4462 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2331,7 +2331,7 @@ EXPORT_SYMBOL(udp_proc_unregister);
2331 2331
2332/* ------------------------------------------------------------------------ */ 2332/* ------------------------------------------------------------------------ */
2333static void udp4_format_sock(struct sock *sp, struct seq_file *f, 2333static void udp4_format_sock(struct sock *sp, struct seq_file *f,
2334 int bucket, int *len) 2334 int bucket)
2335{ 2335{
2336 struct inet_sock *inet = inet_sk(sp); 2336 struct inet_sock *inet = inet_sk(sp);
2337 __be32 dest = inet->inet_daddr; 2337 __be32 dest = inet->inet_daddr;
@@ -2340,7 +2340,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
2340 __u16 srcp = ntohs(inet->inet_sport); 2340 __u16 srcp = ntohs(inet->inet_sport);
2341 2341
2342 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 2342 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
2343 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d%n", 2343 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d",
2344 bucket, src, srcp, dest, destp, sp->sk_state, 2344 bucket, src, srcp, dest, destp, sp->sk_state,
2345 sk_wmem_alloc_get(sp), 2345 sk_wmem_alloc_get(sp),
2346 sk_rmem_alloc_get(sp), 2346 sk_rmem_alloc_get(sp),
@@ -2348,23 +2348,22 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
2348 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)), 2348 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
2349 0, sock_i_ino(sp), 2349 0, sock_i_ino(sp),
2350 atomic_read(&sp->sk_refcnt), sp, 2350 atomic_read(&sp->sk_refcnt), sp,
2351 atomic_read(&sp->sk_drops), len); 2351 atomic_read(&sp->sk_drops));
2352} 2352}
2353 2353
2354int udp4_seq_show(struct seq_file *seq, void *v) 2354int udp4_seq_show(struct seq_file *seq, void *v)
2355{ 2355{
2356 seq_setwidth(seq, 127);
2356 if (v == SEQ_START_TOKEN) 2357 if (v == SEQ_START_TOKEN)
2357 seq_printf(seq, "%-127s\n", 2358 seq_puts(seq, " sl local_address rem_address st tx_queue "
2358 " sl local_address rem_address st tx_queue "
2359 "rx_queue tr tm->when retrnsmt uid timeout " 2359 "rx_queue tr tm->when retrnsmt uid timeout "
2360 "inode ref pointer drops"); 2360 "inode ref pointer drops");
2361 else { 2361 else {
2362 struct udp_iter_state *state = seq->private; 2362 struct udp_iter_state *state = seq->private;
2363 int len;
2364 2363
2365 udp4_format_sock(v, seq, state->bucket, &len); 2364 udp4_format_sock(v, seq, state->bucket);
2366 seq_printf(seq, "%*s\n", 127 - len, "");
2367 } 2365 }
2366 seq_pad(seq, '\n');
2368 return 0; 2367 return 0;
2369} 2368}
2370 2369