Skip to content

Commit

Permalink
Fix populating blacklists.
Browse files Browse the repository at this point in the history
When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).
  • Loading branch information
bogdan-iancu committed Jul 11, 2016
1 parent 97f309c commit 7fa9cee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/load_balancer/lb_bl.c
Expand Up @@ -189,8 +189,8 @@ int populate_lb_bls(struct lb_dst *dest_list)
add_rule_to_list( &lbbl_first, &lbbl_last,
group_net,
NULL/*body*/,
0/*port*/,
PROTO_NONE/*proto*/,
dst->ports[j],
dst->protos[j],
0/*flags*/);
pkg_free(group_net);
}
Expand Down
7 changes: 5 additions & 2 deletions modules/load_balancer/lb_data.c
Expand Up @@ -303,15 +303,18 @@ int add_lb_dsturi( struct lb_data *data, int id, int group, char *uri,
}
hostent2ip_addr( &dst->ips[0], &proxy->host, proxy->addr_idx);
dst->ports[0] = proxy->port;
dst->protos[0] = proxy->proto;
dst->ips_cnt = 1;
LM_DBG("first dst ip addr [%s]:%d\n",
ip_addr2a(&dst->ips[0]), dst->ports[0]);
/* get the next available IPs from DNS */
while (dst->ips_cnt<LB_MAX_IPS && (get_next_su( proxy, &sau, 0)==0) ) {
su2ip_addr( &dst->ips[dst->ips_cnt], &sau);
dst->ports[dst->ips_cnt] = proxy->port;
LM_DBG("additional dst ip addr [%s]:%d\n",
ip_addr2a(&dst->ips[dst->ips_cnt]), dst->ports[dst->ips_cnt]);
dst->protos[dst->ips_cnt] = proxy->proto;
LM_DBG("additional dst ip addr [%s]:%d, proto %d\n",
ip_addr2a(&dst->ips[dst->ips_cnt]),
dst->ports[dst->ips_cnt], dst->protos[dst->ips_cnt] );
/* one more IP found */
dst->ips_cnt++;
}
Expand Down
1 change: 1 addition & 0 deletions modules/load_balancer/lb_data.h
Expand Up @@ -73,6 +73,7 @@ struct lb_dst {
struct lb_resource_map *rmap;
struct ip_addr ips[LB_MAX_IPS]; /* IP-Address of the entry */
unsigned short int ports[LB_MAX_IPS]; /* Port of the request URI */
unsigned short int protos[LB_MAX_IPS]; /* Protocol of the request URI */
unsigned short ips_cnt;
struct lb_dst *next;
};
Expand Down

0 comments on commit 7fa9cee

Please sign in to comment.