Commit f3cc2ea7 authored by robertdavidgraham's avatar robertdavidgraham
Browse files

enough buffers

parent 1d3001e8
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -99,7 +99,8 @@ masscan_echo(struct Masscan *masscan, FILE *fp)
    fprintf(fp, "randomize-hosts = true\n");
    fprintf(fp, "seed = %llu\n", masscan->seed);
    fprintf(fp, "shard = %u/%u\n", masscan->shard.one, masscan->shard.of);

    if (masscan->is_banners)
        fprintf(fp, "banners = true\n");

    fprintf(fp, "# ADAPTER SETTINGS\n");
    fprintf(fp, "adapter = %s\n", masscan->ifname);
@@ -364,6 +365,8 @@ parse_mac_address(const char *text, unsigned char *mac)
    return 0;
}

/***************************************************************************
 ***************************************************************************/
static uint64_t
parseInt(const char *str)
{
@@ -376,6 +379,17 @@ parseInt(const char *str)
    return result;
}

/***************************************************************************
 * Parses the number of seconds (for rotating files mostly). We do a little
 * more than just parse an integer. We support strings like:
 *
 * hourly
 * daily
 * Week
 * 5days
 * 10-months
 * 3600
 ***************************************************************************/
static uint64_t
parseTime(const char *value)
{
@@ -398,7 +412,7 @@ parseTime(const char *value)
        num = 1;

    if (value[0] == '\0')
        return 0;
        return num;

    switch (tolower(value[0])) {
    case 's':
@@ -432,7 +446,15 @@ parseTime(const char *value)



int EQUALS(const char *lhs, const char *rhs)
/***************************************************************************
 * Tests if the named parameter on the command-line. We do a little
 * more than a straight string compare, because I get confused 
 * whether parameter have punctuation. Is it "--excludefile" or
 * "--exclude-file"? I don't know if it's got that dash. Screw it,
 * I'll just make the code so it don't care.
 ***************************************************************************/
static int
EQUALS(const char *lhs, const char *rhs)
{
    for (;;) {
        while (*lhs == '-' || *lhs == '.')
@@ -472,7 +494,7 @@ masscan_set_parameter(struct Masscan *masscan,
            struct Range range;

            range = range_parse_ipv4(value, 0, 0);
            if (range.begin == 0 && range.end == 0) {
            if (range.begin > range.end) {
                fprintf(stderr, "CONF: bad source IPv4 address: %s=%s\n", 
                        name, value);
                return;
+4 −3
Original line number Diff line number Diff line
@@ -725,11 +725,12 @@ main_scan(struct Masscan *masscan)
    /*
     * Allocate packet buffers for sending
     */
    masscan->packet_buffers = rte_ring_create(256, RING_F_SP_ENQ|RING_F_SC_DEQ);
    masscan->transmit_queue = rte_ring_create(256, RING_F_SP_ENQ|RING_F_SC_DEQ);
#define BUFFER_COUNT 16384
    masscan->packet_buffers = rte_ring_create(BUFFER_COUNT, RING_F_SP_ENQ|RING_F_SC_DEQ);
    masscan->transmit_queue = rte_ring_create(BUFFER_COUNT, RING_F_SP_ENQ|RING_F_SC_DEQ);
    {
        unsigned i;
        for (i=0; i<255 /*TODO: why not 256???*/; i++) {
        for (i=0; i<BUFFER_COUNT-1; i++) {
            struct PacketBuffer *p = (struct PacketBuffer *)malloc(sizeof(*p));
            err = rte_ring_sp_enqueue(masscan->packet_buffers, p);
            if (err) {
+4 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "string_s.h"

uint64_t global_tcb_count;
unsigned global_recv_overwhelmed;

struct TCP_Control_Block
{
@@ -339,7 +340,9 @@ tcpcon_send_packet(
    for (err=1; err; ) {
        err = rte_ring_sc_dequeue(tcpcon->packet_buffers, (void**)&response);
        if (err != 0) {
            LOG(0, "packet buffers empty (should be impossible)\n");
            //LOG(0, "packet buffers empty (should be impossible)\n");
            printf("+");
            fflush(stdout);
            pixie_usleep(100); /* no packet available */
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ int arp_response(
    for (err=1; err; ) {
        err = rte_ring_sc_dequeue(packet_buffers, (void**)&response);
        if (err != 0) {
            LOG(0, "packet buffers empty (should be impossible)\n");
            //LOG(0, "packet buffers empty (should be impossible)\n");
            pixie_usleep(100);
        }
    }