Commit bbf852b9 authored by Christoph Paasch's avatar Christoph Paasch Committed by David S. Miller

tcp: metrics: Delete all entries matching a certain destination

As we now can have multiple entries per destination-IP, the "ip
tcp_metrics delete address ADDRESS" command deletes all of them.
Signed-off-by: default avatarChristoph Paasch <christoph.paasch@uclouvain.be>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8a59359c
...@@ -982,7 +982,7 @@ static int tcp_metrics_flush_all(struct net *net) ...@@ -982,7 +982,7 @@ static int tcp_metrics_flush_all(struct net *net)
static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info) static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
{ {
struct tcpm_hash_bucket *hb; struct tcpm_hash_bucket *hb;
struct tcp_metrics_block *tm; struct tcp_metrics_block *tm, *tmlist = NULL;
struct tcp_metrics_block __rcu **pp; struct tcp_metrics_block __rcu **pp;
struct inetpeer_addr daddr; struct inetpeer_addr daddr;
unsigned int hash; unsigned int hash;
...@@ -999,17 +999,22 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info) ...@@ -999,17 +999,22 @@ static int tcp_metrics_nl_cmd_del(struct sk_buff *skb, struct genl_info *info)
hb = net->ipv4.tcp_metrics_hash + hash; hb = net->ipv4.tcp_metrics_hash + hash;
pp = &hb->chain; pp = &hb->chain;
spin_lock_bh(&tcp_metrics_lock); spin_lock_bh(&tcp_metrics_lock);
for (tm = deref_locked_genl(*pp); tm; for (tm = deref_locked_genl(*pp); tm; tm = deref_locked_genl(*pp)) {
pp = &tm->tcpm_next, tm = deref_locked_genl(*pp)) {
if (addr_same(&tm->tcpm_daddr, &daddr)) { if (addr_same(&tm->tcpm_daddr, &daddr)) {
*pp = tm->tcpm_next; *pp = tm->tcpm_next;
break; tm->tcpm_next = tmlist;
tmlist = tm;
} else {
pp = &tm->tcpm_next;
} }
} }
spin_unlock_bh(&tcp_metrics_lock); spin_unlock_bh(&tcp_metrics_lock);
if (!tm) if (!tmlist)
return -ESRCH; return -ESRCH;
kfree_rcu(tm, rcu_head); for (tm = tmlist; tm; tm = tmlist) {
tmlist = tm->tcpm_next;
kfree_rcu(tm, rcu_head);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment