#include <linux/file.h>
#include <linux/inetdevice.h>
#include <linux/module.h>
+#include <linux/miscdevice.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter/xt_qtaguid.h>
#include <linux/ratelimit.h>
"uid=%u sk=%p dir=%d proto=%d bytes=%d)\n",
ifname, uid, sk, direction, proto, bytes);
-
+ spin_lock_bh(&iface_stat_list_lock);
iface_entry = get_iface_entry(ifname);
if (!iface_entry) {
pr_err_ratelimited("qtaguid: iface_stat: stat_update() "
"%s not found\n", ifname);
+ spin_unlock_bh(&iface_stat_list_lock);
return;
}
/* It is ok to process data when an iface_entry is inactive */
* {0, uid_tag} will also get updated.
*/
tag_stat_update(tag_stat_entry, direction, proto, bytes);
- spin_unlock_bh(&iface_entry->tag_stat_list_lock);
- return;
+ goto unlock;
}
/* Loop over tag list under this interface for {0,uid_tag} */
tag_stat_update(new_tag_stat, direction, proto, bytes);
unlock:
spin_unlock_bh(&iface_entry->tag_stat_list_lock);
+ spin_unlock_bh(&iface_stat_list_lock);
}
static int iface_netdev_event_handler(struct notifier_block *nb,
switch (par->family) {
case NFPROTO_IPV6:
- sk = xt_socket_get6_sk(skb, par);
+ sk = xt_socket_lookup_slow_v6(dev_net(skb->dev), skb, par->in);
break;
case NFPROTO_IPV4:
- sk = xt_socket_get4_sk(skb, par);
+ sk = xt_socket_lookup_slow_v4(dev_net(skb->dev), skb, par->in);
break;
default:
return NULL;
* "struct inet_timewait_sock" which is missing fields.
*/
if (sk->sk_state == TCP_TIME_WAIT) {
- xt_socket_put_sk(sk);
+ sock_gen_put(sk);
sk = NULL;
}
}
put_sock_ret_res:
if (got_sock)
- xt_socket_put_sk(sk);
+ sock_gen_put(sk);
if (set_sk_callback_lock)
read_unlock_bh(&sk->sk_callback_lock);
ret_res:
static int pp_stats_line(struct seq_file *m, struct tag_stat *ts_entry,
int cnt_set)
{
- int ret;
struct data_counters *cnts;
tag_t tag = ts_entry->tn.tag;
uid_t stat_uid = get_uid_from_tag(tag);
}
ppi->item_index++;
cnts = &ts_entry->counters;
- ret = seq_printf(m, "%d %s 0x%llx %u %u "
+ seq_printf(m, "%d %s 0x%llx %u %u "
"%llu %llu "
"%llu %llu "
"%llu %llu "
cnts->bpc[cnt_set][IFS_TX][IFS_UDP].packets,
cnts->bpc[cnt_set][IFS_TX][IFS_PROTO_OTHER].bytes,
cnts->bpc[cnt_set][IFS_TX][IFS_PROTO_OTHER].packets);
- return ret ?: 1;
+ return seq_has_overflowed(m) ? -ENOSPC : 1;
}
static bool pp_sets(struct seq_file *m, struct tag_stat *ts_entry)