Ejemplo n.º 1
0
static int connbytes_mt_check(const struct xt_mtchk_param *par)
{
    const struct xt_connbytes_info *sinfo = par->matchinfo;
    int ret;

    if (sinfo->what != XT_CONNBYTES_PKTS &&
            sinfo->what != XT_CONNBYTES_BYTES &&
            sinfo->what != XT_CONNBYTES_AVGPKT)
        return -EINVAL;

    if (sinfo->direction != XT_CONNBYTES_DIR_ORIGINAL &&
            sinfo->direction != XT_CONNBYTES_DIR_REPLY &&
            sinfo->direction != XT_CONNBYTES_DIR_BOTH)
        return -EINVAL;

    ret = nf_ct_l3proto_try_module_get(par->family);
    if (ret < 0)
        pr_info("cannot load conntrack support for proto=%u\n",
                par->family);

    /*
     * This filter cannot function correctly unless connection tracking
     * accounting is enabled, so complain in the hope that someone notices.
     */
    if (!nf_ct_acct_enabled(par->net)) {
        pr_warning("Forcing CT accounting to be enabled\n");
        nf_ct_set_acct(par->net, true);
    }

    return ret;
}
Ejemplo n.º 2
0
static bool connbytes_mt_check(const struct xt_mtchk_param *par)
{
	const struct xt_connbytes_info *sinfo = par->matchinfo;

	if (sinfo->what != XT_CONNBYTES_PKTS &&
	    sinfo->what != XT_CONNBYTES_BYTES &&
	    sinfo->what != XT_CONNBYTES_AVGPKT)
		return false;

	if (sinfo->direction != XT_CONNBYTES_DIR_ORIGINAL &&
	    sinfo->direction != XT_CONNBYTES_DIR_REPLY &&
	    sinfo->direction != XT_CONNBYTES_DIR_BOTH)
		return false;

	if (nf_ct_l3proto_try_module_get(par->family) < 0) {
		printk(KERN_WARNING "can't load conntrack support for "
				    "proto=%u\n", par->family);
		return false;
	}

	/*
	 * This filter cannot function correctly unless connection tracking
	 * accounting is enabled, so complain in the hope that someone notices.
	 */
	if (!nf_ct_acct_enabled(&init_net)) {
		pr_warning("Forcing CT accounting to be enabled\n");
		nf_ct_set_acct(&init_net, true);
	}

	return true;
}