[201811][dhcp_relay] Fix sendto: invalid destination address error (#9138)
This commit is contained in:
parent
2da155e8ec
commit
0a9228c965
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "dbconnector.h"
|
#include "dbconnector.h"
|
||||||
#include "configInterface.h"
|
#include "configInterface.h"
|
||||||
#include "table.h"
|
|
||||||
#include "redisclient.h"
|
#include "redisclient.h"
|
||||||
|
|
||||||
|
|
||||||
@ -682,15 +681,15 @@ void dhcp6relay_stop()
|
|||||||
void loop_relay(std::vector<relay_config> *vlans) {
|
void loop_relay(std::vector<relay_config> *vlans) {
|
||||||
std::vector<int> sockets;
|
std::vector<int> sockets;
|
||||||
|
|
||||||
for(std::size_t i = 0; i<vlans->size(); i++) {
|
for(relay_config &vlan : *vlans) {
|
||||||
struct relay_config config = vlans->at(i);
|
relay_config *config = &vlan;
|
||||||
int filter = 0;
|
int filter = 0;
|
||||||
int local_sock = 0;
|
int local_sock = 0;
|
||||||
const char *ifname = config.interface.c_str();
|
const char *ifname = config->interface.c_str();
|
||||||
int index = if_nametoindex(ifname);
|
int index = if_nametoindex(ifname);
|
||||||
|
|
||||||
std::string counterVlan = counter_table;
|
std::string counterVlan = counter_table;
|
||||||
initialize_counter(counterVlan.append(config.interface));
|
initialize_counter(counterVlan.append(config->interface));
|
||||||
|
|
||||||
filter = sock_open(index, ðer_relay_fprog);
|
filter = sock_open(index, ðer_relay_fprog);
|
||||||
|
|
||||||
@ -698,7 +697,7 @@ void loop_relay(std::vector<relay_config> *vlans) {
|
|||||||
sockets.push_back(filter);
|
sockets.push_back(filter);
|
||||||
sockets.push_back(local_sock);
|
sockets.push_back(local_sock);
|
||||||
|
|
||||||
prepare_relay_config(&config, &local_sock, filter);
|
prepare_relay_config(config, &local_sock, filter);
|
||||||
|
|
||||||
evutil_make_listen_socket_reuseable(filter);
|
evutil_make_listen_socket_reuseable(filter);
|
||||||
evutil_make_socket_nonblocking(filter);
|
evutil_make_socket_nonblocking(filter);
|
||||||
@ -711,8 +710,8 @@ void loop_relay(std::vector<relay_config> *vlans) {
|
|||||||
syslog(LOG_ERR, "libevent: Failed to create base\n");
|
syslog(LOG_ERR, "libevent: Failed to create base\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
listen_event = event_new(base, filter, EV_READ|EV_PERSIST, callback, (void *)&config);
|
listen_event = event_new(base, filter, EV_READ|EV_PERSIST, callback, config);
|
||||||
server_listen_event = event_new(base, local_sock, EV_READ|EV_PERSIST, server_callback, (void *)&config);
|
server_listen_event = event_new(base, local_sock, EV_READ|EV_PERSIST, server_callback, config);
|
||||||
if (listen_event == NULL || server_listen_event == NULL) {
|
if (listen_event == NULL || server_listen_event == NULL) {
|
||||||
syslog(LOG_ERR, "libevent: Failed to create libevent\n");
|
syslog(LOG_ERR, "libevent: Failed to create libevent\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user