struct sctp_ht_iter {
struct seq_net_private p;
struct rhashtable_iter hti;
+ int start_fail;
};
static void *sctp_transport_seq_start(struct seq_file *seq, loff_t *pos)
struct sctp_ht_iter *iter = seq->private;
int err = sctp_transport_walk_start(&iter->hti);
- if (err)
+ if (err) {
+ iter->start_fail = 1;
return ERR_PTR(err);
+ }
return sctp_transport_get_idx(seq_file_net(seq), &iter->hti, *pos);
}
{
struct sctp_ht_iter *iter = seq->private;
+ if (iter->start_fail)
+ return;
sctp_transport_walk_stop(&iter->hti);
}
return err;
err = rhashtable_walk_start(iter);
+ if (err && err != -EAGAIN) {
+ rhashtable_walk_exit(iter);
+ return err;
+ }
- return err == -EAGAIN ? 0 : err;
+ return 0;
}
void sctp_transport_walk_stop(struct rhashtable_iter *iter)
int sctp_for_each_transport(int (*cb)(struct sctp_transport *, void *),
struct net *net, int pos, void *p) {
struct rhashtable_iter hti;
- int err = 0;
void *obj;
+ int err;
- if (sctp_transport_walk_start(&hti))
- goto out;
+ err = sctp_transport_walk_start(&hti);
+ if (err)
+ return err;
sctp_transport_get_idx(net, &hti, pos);
obj = sctp_transport_get_next(net, &hti);
if (err)
break;
}
-out:
sctp_transport_walk_stop(&hti);
+
return err;
}
EXPORT_SYMBOL_GPL(sctp_for_each_transport);