Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Aug 2016 09:54:15 -0700
From:      "Lundberg, Johannes" <johannes@brilliantservice.co.jp>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Socket sendmsg() porting question
Message-ID:  <CAASDrVmKcO8Gi%2BROhsKpsSRTCsgx5COvGVX6MpGcS3SDG%2Bj22g@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
SGkNCg0KSSdtIHBvcnRpbmcgYSBwcm9qZWN0IHRvIGZic2QgYW5kIEkgaGF2ZSBwcm9ibGVtIHdp
dGggdGhpcyBwYXJ0IHRoYXQgd29ya3MNCmluIGxpbnV4IGJ1dCBub3QgZmJzZCB3aGVuIGZkID0g
LTEuDQoNCmh0dHBzOi8vZ2l0aHViLmNvbS9DbG91ZGVmL3dsYy9ibG9iL21hc3Rlci9zcmMvc2Vz
c2lvbi9mZC5jI0w4MC1MMTA4DQoNCkkgZ2V0ICJpbnZhbGlkIGFyZ3VtZW50IiBmcm9tIHNlbmRt
c2coKSB3aGVuIHNldHRpbmcgQ01TR19MRU4oMCkuDQoNCkFueW9uZSBoYXZlIGEgY2x1ZSBob3cg
dG8gY29ycmVjdGx5IGRvIHRoaXMgb24gZmJzZD8NCg0KVGhhbmtzIQ0KDQpKb2hhbm5lcw0KCi0t
IAo9LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS09LT0tPS0K
56eY5a+G5L+d5oyB44Gr44Gk44GE44Gm77ya44GT44Gu6Zu75a2Q44Oh44O844Or44Gv44CB5ZCN
5a6b5Lq644Gr6YCB5L+h44GX44Gf44KC44Gu44Gn44GC44KK44CB56eY5Yy/54m55qip44Gu5a++
6LGh44Go44Gq44KL5oOF5aCx44KS5ZCr44KT44Gn44GE44G+44GZ44CCCuOCguOBl+OAgeWQjeWu
m+S6uuS7peWkluOBruaWueOBjOWPl+S/oeOBleOCjOOBn+WgtOWQiOOAgeOBk+OBruODoeODvOOD
q+OBruegtOajhOOAgeOBiuOCiOOBs+OBk+OBruODoeODvOODq+OBq+mWouOBmeOCi+S4gOWIh+OB
rumWi+ekuuOAgQropIflhpnjgIHphY3luIPjgIHjgZ3jga7ku5bjga7liKnnlKjjgIHjgb7jgZ/j
ga/oqJjovInlhoXlrrnjgavln7rjgaXjgY/jgYTjgYvjgarjgovooYzli5XjgoLjgZXjgozjgarj
gYTjgojjgYbjgYrpoZjjgYTnlLPjgZfkuIrjgZLjgb7jgZnjgIIKLS0tCkNPTkZJREVOVElBTElU
WSBOT1RFOiBUaGUgaW5mb3JtYXRpb24gaW4gdGhpcyBlbWFpbCBpcyBjb25maWRlbnRpYWwKYW5k
IGludGVuZGVkIHNvbGVseSBmb3IgdGhlIGFkZHJlc3NlZS4KRGlzY2xvc3VyZSwgY29weWluZywg
ZGlzdHJpYnV0aW9uIG9yIGFueSBvdGhlciBhY3Rpb24gb2YgdXNlIG9mIHRoaXMKZW1haWwgYnkg
cGVyc29uIG90aGVyIHRoYW4gaW50ZW5kZWQgcmVjaXBpZW50LCBpcyBwcm9oaWJpdGVkLgpJZiB5
b3UgYXJlIG5vdCB0aGUgaW50ZW5kZWQgcmVjaXBpZW50IGFuZCBoYXZlIHJlY2VpdmVkIHRoaXMg
ZW1haWwgaW4KZXJyb3IsIHBsZWFzZSBkZXN0cm95IHRoZSBvcmlnaW5hbCBtZXNzYWdlLgo=
From owner-freebsd-current@freebsd.org  Wed Aug  3 17:12:23 2016
Return-Path: <owner-freebsd-current@freebsd.org>
Delivered-To: freebsd-current@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C221BAEE97
 for <freebsd-current@mailman.ysv.freebsd.org>;
 Wed,  3 Aug 2016 17:12:23 +0000 (UTC)
 (envelope-from asomers@gmail.com)
Received: from mail-oi0-x229.google.com (mail-oi0-x229.google.com
 [IPv6:2607:f8b0:4003:c06::229])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com",
 Issuer "Google Internet Authority G2" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 1E0161C5C
 for <freebsd-current@freebsd.org>; Wed,  3 Aug 2016 17:12:23 +0000 (UTC)
 (envelope-from asomers@gmail.com)
Received: by mail-oi0-x229.google.com with SMTP id l65so289231870oib.1
 for <freebsd-current@freebsd.org>; Wed, 03 Aug 2016 10:12:23 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:in-reply-to:references:from:date:message-id
 :subject:to:cc;
 bh=KT13Eor/+WJc7SZP+nZXfczOdnGbXRbbCisR5kPbtH4=;
 b=gK8Lqt7s+BH0HY0/R2oGf5ynsqCCPWTcKUNP7Fg9tCGqN++InT51UBHFV2GuUOmdj6
 W1aF+tkK/51EbC5zMSfxNVKl0ajEO1gnB8oExBdCvF58rI5oSXtwcOPqe+Ri92K0RpGG
 Z7X8EZK2nflW/tY45lVaMf2a9n84hSjLyh5PUJd+fQGUMr6U2LhD0Dt75AS2vW4RXML9
 lqcNc1pRpL4ZL7ry+J5EQ9sWJypw4wXG1fULIhoDsaAWF8WQTA5p36uqE9swyWils4MH
 7kR2l7/j+F2W7A+83y+5K2VcQri021JYkcxvSJ+gXwQpeeSV368CpfQoJFumaivcU6vK
 v5+g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
 :date:message-id:subject:to:cc;
 bh=KT13Eor/+WJc7SZP+nZXfczOdnGbXRbbCisR5kPbtH4=;
 b=LM+Sdw3MY3AH9emAGszRDPsfM9A1LUMeWJpUNd/+0HagykBoYu5fnI0zFPusfofyvX
 p6qNB7GDux2kU68bPaWVSVemzsg63nMptBov2Y95aM9EXTQ5VXY0+veH7Wr+qHvYiTrO
 aUU59q1fmRKGFKb+21l0PBq06g1CEcrKiAvgxc63gcF+o/SdkdqhkRO6m3dPcdM80mFG
 poofLdUZ1RPOzFNZoiQb3loAaDOB/AXBnqToPc6FMLevqSm7bMQsZsDtmwTDYv5VVvQr
 bfVZF9hfv5+tc9yD8xMxKBCQpS8FiAEIPNB+ax97WQC7Q+8jyI1MMHIvzAkEHdRI+dax
 RNKg==
X-Gm-Message-State: AEkoouvYOyFNlRdAh+jgRyDAujMYc/Rg+0iK4WW2tHI6I2e/G9PpjkPq1CIJDgUHFtBnHjz50jcIi/08BnPvdA==
X-Received: by 10.202.0.80 with SMTP id 77mr1631744oia.173.1470244342432; Wed,
 03 Aug 2016 10:12:22 -0700 (PDT)
MIME-Version: 1.0
Sender: asomers@gmail.com
Received: by 10.202.196.149 with HTTP; Wed, 3 Aug 2016 10:12:21 -0700 (PDT)
In-Reply-To: <CAASDrVmKcO8Gi+ROhsKpsSRTCsgx5COvGVX6MpGcS3SDG+j22g@mail.gmail.com>
References: <CAASDrVmKcO8Gi+ROhsKpsSRTCsgx5COvGVX6MpGcS3SDG+j22g@mail.gmail.com>
From: Alan Somers <asomers@freebsd.org>
Date: Wed, 3 Aug 2016 11:12:21 -0600
X-Google-Sender-Auth: QrNcQN2Y4cVF8IfQ1s-yHWEkv4I
Message-ID: <CAOtMX2goeBHoPa2mu7euw7gX8prtzJGg6c6bsLJZHYJeagFYDw@mail.gmail.com>
Subject: Re: Socket sendmsg() porting question
To: "Lundberg, Johannes" <johannes@brilliantservice.co.jp>
Cc: FreeBSD Current <freebsd-current@freebsd.org>
Content-Type: text/plain; charset=UTF-8
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
 <freebsd-current.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-current>, 
 <mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current/>;
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-current>, 
 <mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 03 Aug 2016 17:12:23 -0000

On Wed, Aug 3, 2016 at 10:54 AM, Lundberg, Johannes
<johannes@brilliantservice.co.jp> wrote:
> Hi
>
> I'm porting a project to fbsd and I have problem with this part that works
> in linux but not fbsd when fd = -1.
>
> https://github.com/Cloudef/wlc/blob/master/src/session/fd.c#L80-L108
>
> I get "invalid argument" from sendmsg() when setting CMSG_LEN(0).
>
> Anyone have a clue how to correctly do this on fbsd?
>
> Thanks!
>
> Johannes
>

It sounds like you're trying to send an empty cmsg.  The error may
happen because your msg_controllen field is inconsistent with your
cmsg_len field.  You're setting msg_controllen as if there were a full
cmsg, but  then cmsg_len says that there is no cmsg.  Or maybe the
error is because (just guessing) FreeBSD doesn't allow sending empty
or undefined cmsgs.  Notice that cmsg_level and cmsg_type are
undefined in the case where fd == -1.  POSIX doesn't say whether
sendmsg supports empty cmsgs, but why bother?  You could just use send
instead of sendmsg if you're not sending a file descriptor.

-Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAASDrVmKcO8Gi%2BROhsKpsSRTCsgx5COvGVX6MpGcS3SDG%2Bj22g>