refresh_nft_cache() return error status

fixes 037639c07a
This commit is contained in:
Thomas Bernard 2020-06-07 19:56:03 +02:00
parent 037639c07a
commit ed48113355
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 16 additions and 10 deletions

View File

@ -569,31 +569,37 @@ table_cb(const struct nlmsghdr *nlh, void *data)
return result; return result;
} }
void int
refresh_nft_cache_filter(void) refresh_nft_cache_filter(void)
{ {
if (rule_list_filter_validate != RULE_CACHE_VALID) { if (rule_list_filter_validate != RULE_CACHE_VALID) {
refresh_nft_cache(&head_filter, nft_table, nft_forward_chain, NFPROTO_INET); if (refresh_nft_cache(&head_filter, nft_table, nft_forward_chain, NFPROTO_INET) < 0)
return -1;
rule_list_filter_validate = RULE_CACHE_VALID; rule_list_filter_validate = RULE_CACHE_VALID;
} }
return 0;
} }
void int
refresh_nft_cache_peer(void) refresh_nft_cache_peer(void)
{ {
if (rule_list_peer_validate != RULE_CACHE_VALID) { if (rule_list_peer_validate != RULE_CACHE_VALID) {
refresh_nft_cache(&head_peer, nft_table, nft_postrouting_chain, NFPROTO_IPV4); if (refresh_nft_cache(&head_peer, nft_table, nft_postrouting_chain, NFPROTO_IPV4) < 0)
return -1;
rule_list_peer_validate = RULE_CACHE_VALID; rule_list_peer_validate = RULE_CACHE_VALID;
} }
return 0;
} }
void int
refresh_nft_cache_redirect(void) refresh_nft_cache_redirect(void)
{ {
if (rule_list_redirect_validate != RULE_CACHE_VALID) { if (rule_list_redirect_validate != RULE_CACHE_VALID) {
refresh_nft_cache(&head_redirect, nft_table, nft_prerouting_chain, NFPROTO_IPV4); if (refresh_nft_cache(&head_redirect, nft_table, nft_prerouting_chain, NFPROTO_IPV4) < 0)
return -1;
rule_list_redirect_validate = RULE_CACHE_VALID; rule_list_redirect_validate = RULE_CACHE_VALID;
} }
return 0;
} }
void void

View File

@ -134,10 +134,10 @@ rule_set_filter_common(struct nftnl_rule *r, uint8_t family, const char * ifname
uint8_t proto, unsigned short eport, unsigned short iport, uint8_t proto, unsigned short eport, unsigned short iport,
unsigned short rport, const char *descr, const char *handle); unsigned short rport, const char *descr, const char *handle);
struct nftnl_rule *rule_del_handle(rule_t *r); struct nftnl_rule *rule_del_handle(rule_t *r);
void refresh_nft_cache_filter(void); int refresh_nft_cache_filter(void);
void refresh_nft_cache_redirect(void); int refresh_nft_cache_redirect(void);
void refresh_nft_cache_peer(void); int refresh_nft_cache_peer(void);
void refresh_nft_cache(struct rule_list *head, const char *table, const char *chain, uint32_t family); int refresh_nft_cache(struct rule_list *head, const char *table, const char *chain, uint32_t family);
int int
table_op(enum nf_tables_msg_types op, uint16_t family, const char * name); table_op(enum nf_tables_msg_types op, uint16_t family, const char * name);