From owner-freebsd-net@FreeBSD.ORG Mon Jul 15 02:38:01 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8225A5AF for ; Mon, 15 Jul 2013 02:38:01 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com [IPv6:2a00:1450:4010:c04::235]) by mx1.freebsd.org (Postfix) with ESMTP id 10BA013B for ; Mon, 15 Jul 2013 02:38:00 +0000 (UTC) Received: by mail-lb0-f181.google.com with SMTP id w10so8867885lbi.26 for ; Sun, 14 Jul 2013 19:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/CxRIW9bl+zq2vj3T6D2V0WxgvztJLQU8hJ7b4NuZl8=; b=vJb7T//LwtKk0sgOUZt4G5cc9vUF65RcSblKOs/3LrwtXaijJOrzB9Ckr4gHmX1XrR bg4M6PpZCSw7VWNL8ryeSPxuk2RiDfTPyOgkjif5+7eNPyV7ryHmxrgTBw4FP/qWRl0j BMW8lJWu/CkLDhH1Qk92iqdioerI9ojry99Tbtidr5w5amD8pLldTrURop9SEWxFO1Z1 OYMW+4YnXUwGqTa0fLYi/Q1okNdhiyeej2Tlt50yqgN38DtNNvVU4Oj2DytXBONNx8qp zU6scDNAj30A/6iUh+ixOnqCIzU5tFK9J4E3kn3B4DXQDSbRbUliMouu26aas/zzRqiX 1czw== MIME-Version: 1.0 X-Received: by 10.112.125.199 with SMTP id ms7mr23367344lbb.29.1373855879892; Sun, 14 Jul 2013 19:37:59 -0700 (PDT) Received: by 10.114.184.41 with HTTP; Sun, 14 Jul 2013 19:37:59 -0700 (PDT) In-Reply-To: <51E0E2AF.7090404@mail.ru> References: <51E0E2AF.7090404@mail.ru> Date: Mon, 15 Jul 2013 10:37:59 +0800 Message-ID: Subject: Re: SO_REUSEPORT: strange kernel balancer behaviour From: Sepherosa Ziehau To: trafdev Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2013 02:38:01 -0000 On Sat, Jul 13, 2013 at 1:16 PM, trafdev wrote: > Hello. > > Could someone help with following problem of SO_REUSEPORT. The most portable "load balance" between processes listening on the same TCP addr/port probably is: s=socket(); bind(s); listen(s); /* various socketopt and fcntl as you needed */ pid=fork(); if (pid==0) { server_loop(s); exit(1); } server_loop(s); exit(1); Even in Linux or DragonFly SO_REUSEPORT "load balance" between processes listening on the same TCP addr/port was introduced recently, so you probably won't want to rely on it. Best Regards, sephe -- Tomorrow Will Never Die