mirror of
https://github.com/status-im/miniupnp.git
synced 2025-01-13 07:35:05 +00:00
miniupnpd/netfilter_nft: fix get_redirect_rule_by_index()
should fix #462
This commit is contained in:
parent
c8cbf9f6ce
commit
e1f3478519
@ -449,12 +449,13 @@ get_peer_rule_by_index(int index,
|
||||
u_int64_t * packets, u_int64_t * bytes)
|
||||
{
|
||||
rule_t *r;
|
||||
int i = 0;
|
||||
|
||||
d_printf(("get_peer_rule_by_index()\n"));
|
||||
refresh_nft_cache_peer();
|
||||
|
||||
LIST_FOREACH(r, &head_peer, entry) {
|
||||
if (r->index == index) {
|
||||
if (i++ == index) {
|
||||
if (ifname != NULL) {
|
||||
if_indextoname(r->ingress_ifidx, ifname);
|
||||
}
|
||||
@ -551,12 +552,13 @@ get_redirect_rule_by_index(int index,
|
||||
u_int64_t * packets, u_int64_t * bytes)
|
||||
{
|
||||
rule_t *r;
|
||||
int i = 0;
|
||||
|
||||
d_printf(("get_redirect_rule_by_index()\n"));
|
||||
refresh_nft_cache_redirect();
|
||||
|
||||
LIST_FOREACH(r, &head_redirect, entry) {
|
||||
if (r->index == index) {
|
||||
if (i++ == index) {
|
||||
if (ifname != NULL) {
|
||||
if_indextoname(r->ingress_ifidx, ifname);
|
||||
}
|
||||
|
@ -483,11 +483,8 @@ table_cb(const struct nlmsghdr *nlh, void *data)
|
||||
struct nftnl_expr_iter *itr;
|
||||
rule_t *r;
|
||||
char *chain;
|
||||
int index_filter, index_peer, index_redirect;
|
||||
UNUSED(data);
|
||||
|
||||
index_filter = index_peer = index_redirect = 0;
|
||||
|
||||
r = malloc(sizeof(rule_t));
|
||||
|
||||
if (r == NULL) {
|
||||
@ -547,22 +544,16 @@ table_cb(const struct nlmsghdr *nlh, void *data)
|
||||
case RULE_NAT:
|
||||
switch (r->nat_type) {
|
||||
case NFT_NAT_SNAT:
|
||||
r->index = index_peer;
|
||||
LIST_INSERT_HEAD(&head_peer, r, entry);
|
||||
index_peer++;
|
||||
break;
|
||||
case NFT_NAT_DNAT:
|
||||
r->index = index_redirect;
|
||||
LIST_INSERT_HEAD(&head_redirect, r, entry);
|
||||
index_redirect++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RULE_FILTER:
|
||||
r->index = index_filter;
|
||||
LIST_INSERT_HEAD(&head_filter, r, entry);
|
||||
index_filter++;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -75,7 +75,6 @@ typedef struct rule_t {
|
||||
uint64_t bytes;
|
||||
char * desc;
|
||||
uint32_t desc_len;
|
||||
int index;
|
||||
} rule_t;
|
||||
|
||||
LIST_HEAD(rule_list, rule_t);
|
||||
|
Loading…
x
Reference in New Issue
Block a user