コード例 #1
0
ファイル: ebt_among.c プロジェクト: 325116067/semc-qsd8x50
static bool ebt_among_mt_check(const struct xt_mtchk_param *par)
{
	const struct ebt_among_info *info = par->matchinfo;
	const struct ebt_entry_match *em =
		container_of(par->matchinfo, const struct ebt_entry_match, data);
	int expected_length = sizeof(struct ebt_among_info);
	const struct ebt_mac_wormhash *wh_dst, *wh_src;
	int err;

	wh_dst = ebt_among_wh_dst(info);
	wh_src = ebt_among_wh_src(info);
	expected_length += ebt_mac_wormhash_size(wh_dst);
	expected_length += ebt_mac_wormhash_size(wh_src);

	if (em->match_size != EBT_ALIGN(expected_length)) {
		printk(KERN_WARNING
		       "ebtables: among: wrong size: %d "
		       "against expected %d, rounded to %Zd\n",
		       em->match_size, expected_length,
		       EBT_ALIGN(expected_length));
		return false;
	}
	if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
		printk(KERN_WARNING
		       "ebtables: among: dst integrity fail: %x\n", -err);
		return false;
	}
	if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
		printk(KERN_WARNING
		       "ebtables: among: src integrity fail: %x\n", -err);
		return false;
	}
	return true;
}
コード例 #2
0
ファイル: ebt_among.c プロジェクト: tidatida/lagopus
static int ebt_among_mt_check(const struct xt_mtchk_param *par) {
  const struct ebt_among_info *info = par->matchinfo;
  const struct ebt_entry_match *em =
    container_of(par->matchinfo, const struct ebt_entry_match, data);
  int expected_length = sizeof(struct ebt_among_info);
  const struct ebt_mac_wormhash *wh_dst, *wh_src;
  int err;

  wh_dst = ebt_among_wh_dst(info);
  wh_src = ebt_among_wh_src(info);
  expected_length += ebt_mac_wormhash_size(wh_dst);
  expected_length += ebt_mac_wormhash_size(wh_src);

  if (em->match_size != EBT_ALIGN(expected_length)) {
    pr_info("wrong size: %d against expected %d, rounded to %Zd\n",
            em->match_size, expected_length,
            EBT_ALIGN(expected_length));
    return -EINVAL;
  }
  if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
    pr_info("dst integrity fail: %x\n", -err);
    return -EINVAL;
  }
  if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
    pr_info("src integrity fail: %x\n", -err);
    return -EINVAL;
  }
  return 0;
}
コード例 #3
0
static int ebt_among_check(const char *tablename, unsigned int hookmask,
			   const struct ebt_entry *e, void *data,
			   unsigned int datalen)
{
	const struct ebt_among_info *info = data;
	int expected_length = sizeof(struct ebt_among_info);
	const struct ebt_mac_wormhash *wh_dst, *wh_src;
	int err;

	wh_dst = ebt_among_wh_dst(info);
	wh_src = ebt_among_wh_src(info);
	expected_length += ebt_mac_wormhash_size(wh_dst);
	expected_length += ebt_mac_wormhash_size(wh_src);

	if (datalen != EBT_ALIGN(expected_length)) {
		printk(KERN_WARNING
		       "ebtables: among: wrong size: %d "
		       "against expected %d, rounded to %Zd\n",
		       datalen, expected_length,
		       EBT_ALIGN(expected_length));
		return -EINVAL;
	}
	if (wh_dst && (err = ebt_mac_wormhash_check_integrity(wh_dst))) {
		printk(KERN_WARNING
		       "ebtables: among: dst integrity fail: %x\n", -err);
		return -EINVAL;
	}
	if (wh_src && (err = ebt_mac_wormhash_check_integrity(wh_src))) {
		printk(KERN_WARNING
		       "ebtables: among: src integrity fail: %x\n", -err);
		return -EINVAL;
	}
	return 0;
}