aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-10-27 17:43:45 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-11-05 14:11:02 -0500
commite71456ae9871f53868befd08b1d192ca93ce0753 (patch)
tree4bd0122380d1d7007b080d29de0b6a64f4bd2f5a
parent824f1fbee7bbbd850cdb62d3f95143fad4719e20 (diff)
netfilter: Remove checks of seq_printf() return values
The return value of seq_printf() is soon to be removed. Remove the checks from seq_printf() in favor of seq_has_overflowed(). Link: http://lkml.kernel.org/r/20141104142236.GA10239@salvia Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> Cc: Patrick McHardy <kaber@trash.net> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Cc: netfilter-devel@vger.kernel.org Cc: coreteam@netfilter.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c36
-rw-r--r--net/netfilter/nf_conntrack_standalone.c60
-rw-r--r--net/netfilter/nf_log.c30
-rw-r--r--net/netfilter/nfnetlink_queue_core.c13
-rw-r--r--net/netfilter/x_tables.c19
-rw-r--r--net/netfilter/xt_hashlimit.c36
6 files changed, 97 insertions, 97 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
index d927f9e72130..a460a87e14f8 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -94,7 +94,7 @@ static void ct_seq_stop(struct seq_file *s, void *v)
94} 94}
95 95
96#ifdef CONFIG_NF_CONNTRACK_SECMARK 96#ifdef CONFIG_NF_CONNTRACK_SECMARK
97static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) 97static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
98{ 98{
99 int ret; 99 int ret;
100 u32 len; 100 u32 len;
@@ -102,17 +102,15 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
102 102
103 ret = security_secid_to_secctx(ct->secmark, &secctx, &len); 103 ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
104 if (ret) 104 if (ret)
105 return 0; 105 return;
106 106
107 ret = seq_printf(s, "secctx=%s ", secctx); 107 seq_printf(s, "secctx=%s ", secctx);
108 108
109 security_release_secctx(secctx, len); 109 security_release_secctx(secctx, len);
110 return ret;
111} 110}
112#else 111#else
113static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) 112static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
114{ 113{
115 return 0;
116} 114}
117#endif 115#endif
118 116
@@ -141,11 +139,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
141 NF_CT_ASSERT(l4proto); 139 NF_CT_ASSERT(l4proto);
142 140
143 ret = -ENOSPC; 141 ret = -ENOSPC;
144 if (seq_printf(s, "%-8s %u %ld ", 142 seq_printf(s, "%-8s %u %ld ",
145 l4proto->name, nf_ct_protonum(ct), 143 l4proto->name, nf_ct_protonum(ct),
146 timer_pending(&ct->timeout) 144 timer_pending(&ct->timeout)
147 ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0) 145 ? (long)(ct->timeout.expires - jiffies)/HZ : 0);
148 goto release;
149 146
150 if (l4proto->print_conntrack) 147 if (l4proto->print_conntrack)
151 l4proto->print_conntrack(s, ct); 148 l4proto->print_conntrack(s, ct);
@@ -163,8 +160,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
163 goto release; 160 goto release;
164 161
165 if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) 162 if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
166 if (seq_printf(s, "[UNREPLIED] ")) 163 seq_printf(s, "[UNREPLIED] ");
167 goto release;
168 164
169 print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 165 print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
170 l3proto, l4proto); 166 l3proto, l4proto);
@@ -176,19 +172,19 @@ static int ct_seq_show(struct seq_file *s, void *v)
176 goto release; 172 goto release;
177 173
178 if (test_bit(IPS_ASSURED_BIT, &ct->status)) 174 if (test_bit(IPS_ASSURED_BIT, &ct->status))
179 if (seq_printf(s, "[ASSURED] ")) 175 seq_printf(s, "[ASSURED] ");
180 goto release;
181 176
182#ifdef CONFIG_NF_CONNTRACK_MARK 177#ifdef CONFIG_NF_CONNTRACK_MARK
183 if (seq_printf(s, "mark=%u ", ct->mark)) 178 seq_printf(s, "mark=%u ", ct->mark);
184 goto release;
185#endif 179#endif
186 180
187 if (ct_show_secctx(s, ct)) 181 ct_show_secctx(s, ct);
188 goto release; 182
183 seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use));
189 184
190 if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) 185 if (seq_has_overflowed(s))
191 goto release; 186 goto release;
187
192 ret = 0; 188 ret = 0;
193release: 189release:
194 nf_ct_put(ct); 190 nf_ct_put(ct);
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 23a0dcab21d4..fc823fa5dcf5 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -120,7 +120,7 @@ static void ct_seq_stop(struct seq_file *s, void *v)
120} 120}
121 121
122#ifdef CONFIG_NF_CONNTRACK_SECMARK 122#ifdef CONFIG_NF_CONNTRACK_SECMARK
123static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) 123static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
124{ 124{
125 int ret; 125 int ret;
126 u32 len; 126 u32 len;
@@ -128,22 +128,20 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
128 128
129 ret = security_secid_to_secctx(ct->secmark, &secctx, &len); 129 ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
130 if (ret) 130 if (ret)
131 return 0; 131 return;
132 132
133 ret = seq_printf(s, "secctx=%s ", secctx); 133 seq_printf(s, "secctx=%s ", secctx);
134 134
135 security_release_secctx(secctx, len); 135 security_release_secctx(secctx, len);
136 return ret;
137} 136}
138#else 137#else
139static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct) 138static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
140{ 139{
141 return 0;
142} 140}
143#endif 141#endif
144 142
145#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP 143#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
146static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) 144static void ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
147{ 145{
148 struct ct_iter_state *st = s->private; 146 struct ct_iter_state *st = s->private;
149 struct nf_conn_tstamp *tstamp; 147 struct nf_conn_tstamp *tstamp;
@@ -157,16 +155,15 @@ static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
157 else 155 else
158 delta_time = 0; 156 delta_time = 0;
159 157
160 return seq_printf(s, "delta-time=%llu ", 158 seq_printf(s, "delta-time=%llu ",
161 (unsigned long long)delta_time); 159 (unsigned long long)delta_time);
162 } 160 }
163 return 0; 161 return;
164} 162}
165#else 163#else
166static inline int 164static inline void
167ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct) 165ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
168{ 166{
169 return 0;
170} 167}
171#endif 168#endif
172 169
@@ -193,12 +190,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
193 NF_CT_ASSERT(l4proto); 190 NF_CT_ASSERT(l4proto);
194 191
195 ret = -ENOSPC; 192 ret = -ENOSPC;
196 if (seq_printf(s, "%-8s %u %-8s %u %ld ", 193 seq_printf(s, "%-8s %u %-8s %u %ld ",
197 l3proto->name, nf_ct_l3num(ct), 194 l3proto->name, nf_ct_l3num(ct),
198 l4proto->name, nf_ct_protonum(ct), 195 l4proto->name, nf_ct_protonum(ct),
199 timer_pending(&ct->timeout) 196 timer_pending(&ct->timeout)
200 ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0) 197 ? (long)(ct->timeout.expires - jiffies)/HZ : 0);
201 goto release;
202 198
203 if (l4proto->print_conntrack) 199 if (l4proto->print_conntrack)
204 l4proto->print_conntrack(s, ct); 200 l4proto->print_conntrack(s, ct);
@@ -206,12 +202,14 @@ static int ct_seq_show(struct seq_file *s, void *v)
206 print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 202 print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
207 l3proto, l4proto); 203 l3proto, l4proto);
208 204
205 if (seq_has_overflowed(s))
206 goto release;
207
209 if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL)) 208 if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
210 goto release; 209 goto release;
211 210
212 if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status))) 211 if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
213 if (seq_printf(s, "[UNREPLIED] ")) 212 seq_printf(s, "[UNREPLIED] ");
214 goto release;
215 213
216 print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, 214 print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
217 l3proto, l4proto); 215 l3proto, l4proto);
@@ -220,26 +218,26 @@ static int ct_seq_show(struct seq_file *s, void *v)
220 goto release; 218 goto release;
221 219
222 if (test_bit(IPS_ASSURED_BIT, &ct->status)) 220 if (test_bit(IPS_ASSURED_BIT, &ct->status))
223 if (seq_printf(s, "[ASSURED] ")) 221 seq_printf(s, "[ASSURED] ");
224 goto release;
225 222
226#if defined(CONFIG_NF_CONNTRACK_MARK) 223 if (seq_has_overflowed(s))
227 if (seq_printf(s, "mark=%u ", ct->mark))
228 goto release; 224 goto release;
225
226#if defined(CONFIG_NF_CONNTRACK_MARK)
227 seq_printf(s, "mark=%u ", ct->mark);
229#endif 228#endif
230 229
231 if (ct_show_secctx(s, ct)) 230 ct_show_secctx(s, ct);
232 goto release;
233 231
234#ifdef CONFIG_NF_CONNTRACK_ZONES 232#ifdef CONFIG_NF_CONNTRACK_ZONES
235 if (seq_printf(s, "zone=%u ", nf_ct_zone(ct))) 233 seq_printf(s, "zone=%u ", nf_ct_zone(ct));
236 goto release;
237#endif 234#endif
238 235
239 if (ct_show_delta_time(s, ct)) 236 ct_show_delta_time(s, ct);
240 goto release; 237
238 seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use));
241 239
242 if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use))) 240 if (seq_has_overflowed(s))
243 goto release; 241 goto release;
244 242
245 ret = 0; 243 ret = 0;
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index d7197649dba6..6e3b9117db1f 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -294,19 +294,19 @@ static int seq_show(struct seq_file *s, void *v)
294{ 294{
295 loff_t *pos = v; 295 loff_t *pos = v;
296 const struct nf_logger *logger; 296 const struct nf_logger *logger;
297 int i, ret; 297 int i;
298 struct net *net = seq_file_net(s); 298 struct net *net = seq_file_net(s);
299 299
300 logger = rcu_dereference_protected(net->nf.nf_loggers[*pos], 300 logger = rcu_dereference_protected(net->nf.nf_loggers[*pos],
301 lockdep_is_held(&nf_log_mutex)); 301 lockdep_is_held(&nf_log_mutex));
302 302
303 if (!logger) 303 if (!logger)
304 ret = seq_printf(s, "%2lld NONE (", *pos); 304 seq_printf(s, "%2lld NONE (", *pos);
305 else 305 else
306 ret = seq_printf(s, "%2lld %s (", *pos, logger->name); 306 seq_printf(s, "%2lld %s (", *pos, logger->name);
307 307
308 if (ret < 0) 308 if (seq_has_overflowed(s))
309 return ret; 309 return -ENOSPC;
310 310
311 for (i = 0; i < NF_LOG_TYPE_MAX; i++) { 311 for (i = 0; i < NF_LOG_TYPE_MAX; i++) {
312 if (loggers[*pos][i] == NULL) 312 if (loggers[*pos][i] == NULL)
@@ -314,17 +314,19 @@ static int seq_show(struct seq_file *s, void *v)
314 314
315 logger = rcu_dereference_protected(loggers[*pos][i], 315 logger = rcu_dereference_protected(loggers[*pos][i],
316 lockdep_is_held(&nf_log_mutex)); 316 lockdep_is_held(&nf_log_mutex));
317 ret = seq_printf(s, "%s", logger->name); 317 seq_printf(s, "%s", logger->name);
318 if (ret < 0) 318 if (i == 0 && loggers[*pos][i + 1] != NULL)
319 return ret; 319 seq_printf(s, ",");
320 if (i == 0 && loggers[*pos][i + 1] != NULL) { 320
321 ret = seq_printf(s, ","); 321 if (seq_has_overflowed(s))
322 if (ret < 0) 322 return -ENOSPC;
323 return ret;
324 }
325 } 323 }
326 324
327 return seq_printf(s, ")\n"); 325 seq_printf(s, ")\n");
326
327 if (seq_has_overflowed(s))
328 return -ENOSPC;
329 return 0;
328} 330}
329 331
330static const struct seq_operations nflog_seq_ops = { 332static const struct seq_operations nflog_seq_ops = {
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index a82077d9f59b..f823f1538c4f 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -1242,12 +1242,13 @@ static int seq_show(struct seq_file *s, void *v)
1242{ 1242{
1243 const struct nfqnl_instance *inst = v; 1243 const struct nfqnl_instance *inst = v;
1244 1244
1245 return seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n", 1245 seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n",
1246 inst->queue_num, 1246 inst->queue_num,
1247 inst->peer_portid, inst->queue_total, 1247 inst->peer_portid, inst->queue_total,
1248 inst->copy_mode, inst->copy_range, 1248 inst->copy_mode, inst->copy_range,
1249 inst->queue_dropped, inst->queue_user_dropped, 1249 inst->queue_dropped, inst->queue_user_dropped,
1250 inst->id_sequence, 1); 1250 inst->id_sequence, 1);
1251 return seq_has_overflowed(s);
1251} 1252}
1252 1253
1253static const struct seq_operations nfqnl_seq_ops = { 1254static const struct seq_operations nfqnl_seq_ops = {
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 133eb4772f12..51a459c3c649 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -947,9 +947,10 @@ static int xt_table_seq_show(struct seq_file *seq, void *v)
947{ 947{
948 struct xt_table *table = list_entry(v, struct xt_table, list); 948 struct xt_table *table = list_entry(v, struct xt_table, list);
949 949
950 if (strlen(table->name)) 950 if (strlen(table->name)) {
951 return seq_printf(seq, "%s\n", table->name); 951 seq_printf(seq, "%s\n", table->name);
952 else 952 return seq_has_overflowed(seq);
953 } else
953 return 0; 954 return 0;
954} 955}
955 956
@@ -1086,8 +1087,10 @@ static int xt_match_seq_show(struct seq_file *seq, void *v)
1086 if (trav->curr == trav->head) 1087 if (trav->curr == trav->head)
1087 return 0; 1088 return 0;
1088 match = list_entry(trav->curr, struct xt_match, list); 1089 match = list_entry(trav->curr, struct xt_match, list);
1089 return (*match->name == '\0') ? 0 : 1090 if (*match->name == '\0')
1090 seq_printf(seq, "%s\n", match->name); 1091 return 0;
1092 seq_printf(seq, "%s\n", match->name);
1093 return seq_has_overflowed(seq);
1091 } 1094 }
1092 return 0; 1095 return 0;
1093} 1096}
@@ -1139,8 +1142,10 @@ static int xt_target_seq_show(struct seq_file *seq, void *v)
1139 if (trav->curr == trav->head) 1142 if (trav->curr == trav->head)
1140 return 0; 1143 return 0;
1141 target = list_entry(trav->curr, struct xt_target, list); 1144 target = list_entry(trav->curr, struct xt_target, list);
1142 return (*target->name == '\0') ? 0 : 1145 if (*target->name == '\0')
1143 seq_printf(seq, "%s\n", target->name); 1146 return 0;
1147 seq_printf(seq, "%s\n", target->name);
1148 return seq_has_overflowed(seq);
1144 } 1149 }
1145 return 0; 1150 return 0;
1146} 1151}
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 05fbc2a0be46..178696852bde 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -789,7 +789,6 @@ static void dl_seq_stop(struct seq_file *s, void *v)
789static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, 789static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
790 struct seq_file *s) 790 struct seq_file *s)
791{ 791{
792 int res;
793 const struct xt_hashlimit_htable *ht = s->private; 792 const struct xt_hashlimit_htable *ht = s->private;
794 793
795 spin_lock(&ent->lock); 794 spin_lock(&ent->lock);
@@ -798,33 +797,32 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
798 797
799 switch (family) { 798 switch (family) {
800 case NFPROTO_IPV4: 799 case NFPROTO_IPV4:
801 res = seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n", 800 seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",
802 (long)(ent->expires - jiffies)/HZ, 801 (long)(ent->expires - jiffies)/HZ,
803 &ent->dst.ip.src, 802 &ent->dst.ip.src,
804 ntohs(ent->dst.src_port), 803 ntohs(ent->dst.src_port),
805 &ent->dst.ip.dst, 804 &ent->dst.ip.dst,
806 ntohs(ent->dst.dst_port), 805 ntohs(ent->dst.dst_port),
807 ent->rateinfo.credit, ent->rateinfo.credit_cap, 806 ent->rateinfo.credit, ent->rateinfo.credit_cap,
808 ent->rateinfo.cost); 807 ent->rateinfo.cost);
809 break; 808 break;
810#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) 809#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
811 case NFPROTO_IPV6: 810 case NFPROTO_IPV6:
812 res = seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n", 811 seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",
813 (long)(ent->expires - jiffies)/HZ, 812 (long)(ent->expires - jiffies)/HZ,
814 &ent->dst.ip6.src, 813 &ent->dst.ip6.src,
815 ntohs(ent->dst.src_port), 814 ntohs(ent->dst.src_port),
816 &ent->dst.ip6.dst, 815 &ent->dst.ip6.dst,
817 ntohs(ent->dst.dst_port), 816 ntohs(ent->dst.dst_port),
818 ent->rateinfo.credit, ent->rateinfo.credit_cap, 817 ent->rateinfo.credit, ent->rateinfo.credit_cap,
819 ent->rateinfo.cost); 818 ent->rateinfo.cost);
820 break; 819 break;
821#endif 820#endif
822 default: 821 default:
823 BUG(); 822 BUG();
824 res = 0;
825 } 823 }
826 spin_unlock(&ent->lock); 824 spin_unlock(&ent->lock);
827 return res; 825 return seq_has_overflowed(s);
828} 826}
829 827
830static int dl_seq_show(struct seq_file *s, void *v) 828static int dl_seq_show(struct seq_file *s, void *v)