Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Jul 2005 12:59:48 -0400 (EDT)
From:      Tuc at T-B-O-H <ml@t-b-o-h.net>
To:        freebsd-questions@freebsd.org
Subject:   UDP issues over 2K
Message-ID:  <200507051659.j65GxmAK009272@himinbjorg.tucs-beachin-obx-house.com>

next in thread | raw e-mail | index | archive | help
Hi,

	Working with the people doing the INN port, they are complaining
as follows :


I wrote a little test program to try sending a packet over a Unix datagram
socket.  The test program is included below.  I ran it on:

    Debian GNU/Linux (2.4 kernel)
    Solaris 8
    IRIX 6.5
    Tru64 4.0F
    AIX 5.2
    FreeBSD 5.4

All of them handled 8KB packet sizes without any trouble except for Tru64
and FreeBSD, which can't handle a byte over 2KB.  So I'm afraid that INN
is running into (stupidly low) OS-imposed limits that there's no way
around without major surgery in how ctlinnd talks to innd.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>

#define SIZE (8 * 1024)

static void
server(void)
{
    int in;
    struct sockaddr_un server;
    char buffer[SIZE];
    size_t i;
    ssize_t result;
    fd_set readfds;

    in = socket(AF_UNIX, SOCK_DGRAM, 0);
    if (in < 0) {
        perror("socket");
        exit(1);
    }
    memset(&server, 0, sizeof(server));
    server.sun_family = AF_UNIX;
    strcpy(server.sun_path, "sock-s");
    if (bind(in, (struct sockaddr *) &server, sizeof(server)) < 0) {
        perror("bind");
        exit(1);
    }

    FD_ZERO(&readfds);
    FD_SET(in, &readfds);
    if (select(in + 1, &readfds, NULL, NULL, NULL) <= 0) {
        perror("select");
        exit(1);
    }
    result = recv(in, buffer, sizeof(buffer), 0);
    if (result < (ssize_t) sizeof(buffer)) {
        fprintf(stderr, "Only got %ld bytes\n", (long) result);
        exit(1);
    }
    for (i = 0; i < SIZE - 1; i++)
        if (buffer[i] != 1) {
            fprintf(stderr, "Bad data at %lu", (unsigned long) i);
            exit(1);
        }
    if (buffer[i] != 2) {
        fprintf(stderr, "Bad data at %lu", (unsigned long) i);
        exit(1);
    }
    exit(0);
}

static void
client(void)
{
    int out;
    struct sockaddr_un server;
    char buffer[SIZE];
    ssize_t result;

    memset(buffer, 1, sizeof(buffer));
    buffer[sizeof(buffer) - 1] = 2;
    out = socket(AF_UNIX, SOCK_DGRAM, 0);
    memset(&server, 0, sizeof(server));
    server.sun_family = AF_UNIX;
    strcpy(server.sun_path, "sock-s");
    if (sendto(out, buffer, sizeof(buffer), 0, (struct sockaddr *) &server,
               sizeof(server)) < 0) {
        perror("sendto");
        exit(1);
    }
    exit(0);
}

int
main(void)
{
    pid_t child;

    child = fork();
    if (child < 0) {
        perror("fork");
        exit(1);
    } else if (child == 0) {
        sleep(1);
        client();
    } else {
        server();
    }
    return 0;
}



	Is this an issue that they aren't doing something right, or is
it a config error on my part, or just an OS limitation?

			Thanks, Tuc



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507051659.j65GxmAK009272>