mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-20 11:34:57 +02:00
ipset: fast forward to 3.0
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "ip_set_macipmap.h"
|
||||
|
||||
static int
|
||||
macipmap_utest(struct ip_set *set, const void *data, size_t size,
|
||||
macipmap_utest(struct ip_set *set, const void *data, u_int32_t size,
|
||||
ip_set_ip_t *hash_ip)
|
||||
{
|
||||
const struct ip_set_macipmap *map = set->data;
|
||||
@@ -35,8 +35,7 @@ macipmap_utest(struct ip_set *set, const void *data, size_t size,
|
||||
*hash_ip = req->ip;
|
||||
DP("set: %s, ip:%u.%u.%u.%u, %u.%u.%u.%u",
|
||||
set->name, HIPQUAD(req->ip), HIPQUAD(*hash_ip));
|
||||
if (test_bit(IPSET_MACIP_ISSET,
|
||||
(void *) &table[req->ip - map->first_ip].flags)) {
|
||||
if (table[req->ip - map->first_ip].match) {
|
||||
return (memcmp(req->ethernet,
|
||||
&table[req->ip - map->first_ip].ethernet,
|
||||
ETH_ALEN) == 0);
|
||||
@@ -64,8 +63,7 @@ macipmap_ktest(struct ip_set *set,
|
||||
*hash_ip = ip;
|
||||
DP("set: %s, ip:%u.%u.%u.%u, %u.%u.%u.%u",
|
||||
set->name, HIPQUAD(ip), HIPQUAD(*hash_ip));
|
||||
if (test_bit(IPSET_MACIP_ISSET,
|
||||
(void *) &table[ip - map->first_ip].flags)) {
|
||||
if (table[ip - map->first_ip].match) {
|
||||
/* Is mac pointer valid?
|
||||
* If so, compare... */
|
||||
return (skb_mac_header(skb) >= skb->head
|
||||
@@ -88,13 +86,13 @@ macipmap_add(struct ip_set *set, ip_set_ip_t *hash_ip,
|
||||
|
||||
if (ip < map->first_ip || ip > map->last_ip)
|
||||
return -ERANGE;
|
||||
if (test_and_set_bit(IPSET_MACIP_ISSET,
|
||||
(void *) &table[ip - map->first_ip].flags))
|
||||
if (table[ip - map->first_ip].match)
|
||||
return -EEXIST;
|
||||
|
||||
*hash_ip = ip;
|
||||
DP("%u.%u.%u.%u, %u.%u.%u.%u", HIPQUAD(ip), HIPQUAD(*hash_ip));
|
||||
memcpy(&table[ip - map->first_ip].ethernet, ethernet, ETH_ALEN);
|
||||
table[ip - map->first_ip].match = IPSET_MACIP_ISSET;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -114,11 +112,11 @@ macipmap_del(struct ip_set *set, ip_set_ip_t *hash_ip, ip_set_ip_t ip)
|
||||
|
||||
if (ip < map->first_ip || ip > map->last_ip)
|
||||
return -ERANGE;
|
||||
if (!test_and_clear_bit(IPSET_MACIP_ISSET,
|
||||
(void *)&table[ip - map->first_ip].flags))
|
||||
if (!table[ip - map->first_ip].match)
|
||||
return -EEXIST;
|
||||
|
||||
*hash_ip = ip;
|
||||
table[ip - map->first_ip].match = 0;
|
||||
DP("%u.%u.%u.%u, %u.%u.%u.%u", HIPQUAD(ip), HIPQUAD(*hash_ip));
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user