dryrun no longer requires root access
This commit is contained in:
parent
0c83eabfd1
commit
a5eb3d0a8d
12
src/send.c
12
src/send.c
@ -142,6 +142,11 @@ static int get_socket(void)
|
||||
return sock;
|
||||
}
|
||||
|
||||
static int get_dryrun_socket(void)
|
||||
{
|
||||
return socket(AF_INET, SOCK_STREAM, 0);
|
||||
}
|
||||
|
||||
static inline ipaddr_n_t get_src_ip(ipaddr_n_t dst, int local_offset)
|
||||
{
|
||||
if (srcip_first == srcip_last) {
|
||||
@ -156,7 +161,12 @@ int send_run(void)
|
||||
{
|
||||
log_debug("send", "thread started");
|
||||
pthread_mutex_lock(&send_mutex);
|
||||
int sock = get_socket();
|
||||
int sock;
|
||||
if (zconf.dryrun) {
|
||||
sock = get_dryrun_socket();
|
||||
} else {
|
||||
sock = get_socket();
|
||||
}
|
||||
struct sockaddr_ll sockaddr;
|
||||
// get source interface index
|
||||
struct ifreq if_idx;
|
||||
|
10
src/zmap.c
10
src/zmap.c
@ -222,6 +222,7 @@ static void start_zmap(void)
|
||||
}
|
||||
// start threads
|
||||
pthread_t *tsend, trecv, tmon;
|
||||
if (!zconf.dryrun) {
|
||||
int r = pthread_create(&trecv, NULL, start_recv, NULL);
|
||||
if (r != 0) {
|
||||
log_fatal("zmap", "unable to create recv thread");
|
||||
@ -234,18 +235,19 @@ static void start_zmap(void)
|
||||
}
|
||||
pthread_mutex_unlock(&recv_ready_mutex);
|
||||
}
|
||||
}
|
||||
tsend = malloc(zconf.senders * sizeof(pthread_t));
|
||||
assert(tsend);
|
||||
log_debug("zmap", "using %d sender threads", zconf.senders);
|
||||
for (int i=0; i < zconf.senders; i++) {
|
||||
r = pthread_create(&tsend[i], NULL, start_send, NULL);
|
||||
int r = pthread_create(&tsend[i], NULL, start_send, NULL);
|
||||
if (r != 0) {
|
||||
log_fatal("zmap", "unable to create send thread");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
if (!zconf.quiet) {
|
||||
r = pthread_create(&tmon, NULL, start_mon, NULL);
|
||||
int r = pthread_create(&tmon, NULL, start_mon, NULL);
|
||||
if (r != 0) {
|
||||
log_fatal("zmap", "unable to create monitor thread");
|
||||
exit(EXIT_FAILURE);
|
||||
@ -254,14 +256,14 @@ static void start_zmap(void)
|
||||
|
||||
// wait for completion
|
||||
for (int i=0; i < zconf.senders; i++) {
|
||||
pthread_join(tsend[i], NULL);
|
||||
int r = pthread_join(tsend[i], NULL);
|
||||
if (r != 0) {
|
||||
log_fatal("zmap", "unable to join send thread");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
log_debug("zmap", "senders finished");
|
||||
pthread_join(trecv, NULL);
|
||||
int r = pthread_join(trecv, NULL);
|
||||
if (r != 0) {
|
||||
log_fatal("zmap", "unable to join recv thread");
|
||||
exit(EXIT_FAILURE);
|
||||
|
Loading…
Reference in New Issue
Block a user