mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-30 08:04:13 +08:00
ipmr, ip6mr: Unite vif seq functions
Same as previously done with the mfc seq, the logic for the vif seq is refactored to be shared between ipmr and ip6mr. Signed-off-by: Yuval Mintz <yuvalm@mellanox.com> Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c8d6196803
commit
3feda6b46f
@ -206,6 +206,12 @@ static inline void *mr_mfc_find(struct mr_table *mrt, void *hasharg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
|
struct mr_vif_iter {
|
||||||
|
struct seq_net_private p;
|
||||||
|
struct mr_table *mrt;
|
||||||
|
int ct;
|
||||||
|
};
|
||||||
|
|
||||||
struct mr_mfc_iter {
|
struct mr_mfc_iter {
|
||||||
struct seq_net_private p;
|
struct seq_net_private p;
|
||||||
struct mr_table *mrt;
|
struct mr_table *mrt;
|
||||||
@ -216,6 +222,16 @@ struct mr_mfc_iter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_IP_MROUTE_COMMON
|
#ifdef CONFIG_IP_MROUTE_COMMON
|
||||||
|
void *mr_vif_seq_idx(struct net *net, struct mr_vif_iter *iter, loff_t pos);
|
||||||
|
void *mr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos);
|
||||||
|
|
||||||
|
static inline void *mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
|
{
|
||||||
|
return *pos ? mr_vif_seq_idx(seq_file_net(seq),
|
||||||
|
seq->private, *pos - 1)
|
||||||
|
: SEQ_START_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
/* These actually return 'struct mr_mfc *', but to avoid need for explicit
|
/* These actually return 'struct mr_mfc *', but to avoid need for explicit
|
||||||
* castings they simply return void.
|
* castings they simply return void.
|
||||||
*/
|
*/
|
||||||
@ -249,6 +265,23 @@ static inline void mr_mfc_seq_stop(struct seq_file *seq, void *v)
|
|||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
static inline void *mr_vif_seq_idx(struct net *net, struct mr_vif_iter *iter,
|
||||||
|
loff_t pos)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *mr_vif_seq_next(struct seq_file *seq,
|
||||||
|
void *v, loff_t *pos)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void *mr_mfc_seq_idx(struct net *net,
|
static inline void *mr_mfc_seq_idx(struct net *net,
|
||||||
struct mr_mfc_iter *it, loff_t pos)
|
struct mr_mfc_iter *it, loff_t pos)
|
||||||
{
|
{
|
||||||
|
@ -2908,31 +2908,11 @@ out:
|
|||||||
/* The /proc interfaces to multicast routing :
|
/* The /proc interfaces to multicast routing :
|
||||||
* /proc/net/ip_mr_cache & /proc/net/ip_mr_vif
|
* /proc/net/ip_mr_cache & /proc/net/ip_mr_vif
|
||||||
*/
|
*/
|
||||||
struct ipmr_vif_iter {
|
|
||||||
struct seq_net_private p;
|
|
||||||
struct mr_table *mrt;
|
|
||||||
int ct;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct vif_device *ipmr_vif_seq_idx(struct net *net,
|
|
||||||
struct ipmr_vif_iter *iter,
|
|
||||||
loff_t pos)
|
|
||||||
{
|
|
||||||
struct mr_table *mrt = iter->mrt;
|
|
||||||
|
|
||||||
for (iter->ct = 0; iter->ct < mrt->maxvif; ++iter->ct) {
|
|
||||||
if (!VIF_EXISTS(mrt, iter->ct))
|
|
||||||
continue;
|
|
||||||
if (pos-- == 0)
|
|
||||||
return &mrt->vif_table[iter->ct];
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
__acquires(mrt_lock)
|
__acquires(mrt_lock)
|
||||||
{
|
{
|
||||||
struct ipmr_vif_iter *iter = seq->private;
|
struct mr_vif_iter *iter = seq->private;
|
||||||
struct net *net = seq_file_net(seq);
|
struct net *net = seq_file_net(seq);
|
||||||
struct mr_table *mrt;
|
struct mr_table *mrt;
|
||||||
|
|
||||||
@ -2943,26 +2923,7 @@ static void *ipmr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
|||||||
iter->mrt = mrt;
|
iter->mrt = mrt;
|
||||||
|
|
||||||
read_lock(&mrt_lock);
|
read_lock(&mrt_lock);
|
||||||
return *pos ? ipmr_vif_seq_idx(net, seq->private, *pos - 1)
|
return mr_vif_seq_start(seq, pos);
|
||||||
: SEQ_START_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ipmr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|
||||||
{
|
|
||||||
struct ipmr_vif_iter *iter = seq->private;
|
|
||||||
struct net *net = seq_file_net(seq);
|
|
||||||
struct mr_table *mrt = iter->mrt;
|
|
||||||
|
|
||||||
++*pos;
|
|
||||||
if (v == SEQ_START_TOKEN)
|
|
||||||
return ipmr_vif_seq_idx(net, iter, 0);
|
|
||||||
|
|
||||||
while (++iter->ct < mrt->maxvif) {
|
|
||||||
if (!VIF_EXISTS(mrt, iter->ct))
|
|
||||||
continue;
|
|
||||||
return &mrt->vif_table[iter->ct];
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipmr_vif_seq_stop(struct seq_file *seq, void *v)
|
static void ipmr_vif_seq_stop(struct seq_file *seq, void *v)
|
||||||
@ -2973,7 +2934,7 @@ static void ipmr_vif_seq_stop(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
|
static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
struct ipmr_vif_iter *iter = seq->private;
|
struct mr_vif_iter *iter = seq->private;
|
||||||
struct mr_table *mrt = iter->mrt;
|
struct mr_table *mrt = iter->mrt;
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN) {
|
if (v == SEQ_START_TOKEN) {
|
||||||
@ -2996,7 +2957,7 @@ static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
static const struct seq_operations ipmr_vif_seq_ops = {
|
static const struct seq_operations ipmr_vif_seq_ops = {
|
||||||
.start = ipmr_vif_seq_start,
|
.start = ipmr_vif_seq_start,
|
||||||
.next = ipmr_vif_seq_next,
|
.next = mr_vif_seq_next,
|
||||||
.stop = ipmr_vif_seq_stop,
|
.stop = ipmr_vif_seq_stop,
|
||||||
.show = ipmr_vif_seq_show,
|
.show = ipmr_vif_seq_show,
|
||||||
};
|
};
|
||||||
@ -3004,7 +2965,7 @@ static const struct seq_operations ipmr_vif_seq_ops = {
|
|||||||
static int ipmr_vif_open(struct inode *inode, struct file *file)
|
static int ipmr_vif_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
return seq_open_net(inode, file, &ipmr_vif_seq_ops,
|
return seq_open_net(inode, file, &ipmr_vif_seq_ops,
|
||||||
sizeof(struct ipmr_vif_iter));
|
sizeof(struct mr_vif_iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations ipmr_vif_fops = {
|
static const struct file_operations ipmr_vif_fops = {
|
||||||
|
@ -105,6 +105,39 @@ void *mr_mfc_find_any(struct mr_table *mrt, int vifi, void *hasharg)
|
|||||||
EXPORT_SYMBOL(mr_mfc_find_any);
|
EXPORT_SYMBOL(mr_mfc_find_any);
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
|
void *mr_vif_seq_idx(struct net *net, struct mr_vif_iter *iter, loff_t pos)
|
||||||
|
{
|
||||||
|
struct mr_table *mrt = iter->mrt;
|
||||||
|
|
||||||
|
for (iter->ct = 0; iter->ct < mrt->maxvif; ++iter->ct) {
|
||||||
|
if (!VIF_EXISTS(mrt, iter->ct))
|
||||||
|
continue;
|
||||||
|
if (pos-- == 0)
|
||||||
|
return &mrt->vif_table[iter->ct];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(mr_vif_seq_idx);
|
||||||
|
|
||||||
|
void *mr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
||||||
|
{
|
||||||
|
struct mr_vif_iter *iter = seq->private;
|
||||||
|
struct net *net = seq_file_net(seq);
|
||||||
|
struct mr_table *mrt = iter->mrt;
|
||||||
|
|
||||||
|
++*pos;
|
||||||
|
if (v == SEQ_START_TOKEN)
|
||||||
|
return mr_vif_seq_idx(net, iter, 0);
|
||||||
|
|
||||||
|
while (++iter->ct < mrt->maxvif) {
|
||||||
|
if (!VIF_EXISTS(mrt, iter->ct))
|
||||||
|
continue;
|
||||||
|
return &mrt->vif_table[iter->ct];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(mr_vif_seq_next);
|
||||||
|
|
||||||
void *mr_mfc_seq_idx(struct net *net,
|
void *mr_mfc_seq_idx(struct net *net,
|
||||||
struct mr_mfc_iter *it, loff_t pos)
|
struct mr_mfc_iter *it, loff_t pos)
|
||||||
{
|
{
|
||||||
|
@ -337,31 +337,10 @@ static void ip6mr_free_table(struct mr_table *mrt)
|
|||||||
* /proc/ip6_mr_cache /proc/ip6_mr_vif
|
* /proc/ip6_mr_cache /proc/ip6_mr_vif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct ipmr_vif_iter {
|
|
||||||
struct seq_net_private p;
|
|
||||||
struct mr_table *mrt;
|
|
||||||
int ct;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct vif_device *ip6mr_vif_seq_idx(struct net *net,
|
|
||||||
struct ipmr_vif_iter *iter,
|
|
||||||
loff_t pos)
|
|
||||||
{
|
|
||||||
struct mr_table *mrt = iter->mrt;
|
|
||||||
|
|
||||||
for (iter->ct = 0; iter->ct < mrt->maxvif; ++iter->ct) {
|
|
||||||
if (!VIF_EXISTS(mrt, iter->ct))
|
|
||||||
continue;
|
|
||||||
if (pos-- == 0)
|
|
||||||
return &mrt->vif_table[iter->ct];
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
__acquires(mrt_lock)
|
__acquires(mrt_lock)
|
||||||
{
|
{
|
||||||
struct ipmr_vif_iter *iter = seq->private;
|
struct mr_vif_iter *iter = seq->private;
|
||||||
struct net *net = seq_file_net(seq);
|
struct net *net = seq_file_net(seq);
|
||||||
struct mr_table *mrt;
|
struct mr_table *mrt;
|
||||||
|
|
||||||
@ -372,26 +351,7 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
|
|||||||
iter->mrt = mrt;
|
iter->mrt = mrt;
|
||||||
|
|
||||||
read_lock(&mrt_lock);
|
read_lock(&mrt_lock);
|
||||||
return *pos ? ip6mr_vif_seq_idx(net, seq->private, *pos - 1)
|
return mr_vif_seq_start(seq, pos);
|
||||||
: SEQ_START_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *ip6mr_vif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|
||||||
{
|
|
||||||
struct ipmr_vif_iter *iter = seq->private;
|
|
||||||
struct net *net = seq_file_net(seq);
|
|
||||||
struct mr_table *mrt = iter->mrt;
|
|
||||||
|
|
||||||
++*pos;
|
|
||||||
if (v == SEQ_START_TOKEN)
|
|
||||||
return ip6mr_vif_seq_idx(net, iter, 0);
|
|
||||||
|
|
||||||
while (++iter->ct < mrt->maxvif) {
|
|
||||||
if (!VIF_EXISTS(mrt, iter->ct))
|
|
||||||
continue;
|
|
||||||
return &mrt->vif_table[iter->ct];
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ip6mr_vif_seq_stop(struct seq_file *seq, void *v)
|
static void ip6mr_vif_seq_stop(struct seq_file *seq, void *v)
|
||||||
@ -402,7 +362,7 @@ static void ip6mr_vif_seq_stop(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
|
static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
struct ipmr_vif_iter *iter = seq->private;
|
struct mr_vif_iter *iter = seq->private;
|
||||||
struct mr_table *mrt = iter->mrt;
|
struct mr_table *mrt = iter->mrt;
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN) {
|
if (v == SEQ_START_TOKEN) {
|
||||||
@ -424,7 +384,7 @@ static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
static const struct seq_operations ip6mr_vif_seq_ops = {
|
static const struct seq_operations ip6mr_vif_seq_ops = {
|
||||||
.start = ip6mr_vif_seq_start,
|
.start = ip6mr_vif_seq_start,
|
||||||
.next = ip6mr_vif_seq_next,
|
.next = mr_vif_seq_next,
|
||||||
.stop = ip6mr_vif_seq_stop,
|
.stop = ip6mr_vif_seq_stop,
|
||||||
.show = ip6mr_vif_seq_show,
|
.show = ip6mr_vif_seq_show,
|
||||||
};
|
};
|
||||||
@ -432,7 +392,7 @@ static const struct seq_operations ip6mr_vif_seq_ops = {
|
|||||||
static int ip6mr_vif_open(struct inode *inode, struct file *file)
|
static int ip6mr_vif_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
return seq_open_net(inode, file, &ip6mr_vif_seq_ops,
|
return seq_open_net(inode, file, &ip6mr_vif_seq_ops,
|
||||||
sizeof(struct ipmr_vif_iter));
|
sizeof(struct mr_vif_iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations ip6mr_vif_fops = {
|
static const struct file_operations ip6mr_vif_fops = {
|
||||||
|
Loading…
Reference in New Issue
Block a user