From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3FAE340589 for ; Wed, 26 Jan 2022 01:23:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B21068B009; Wed, 26 Jan 2022 03:23:27 +0200 (EET) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 29F0468AEC2 for ; Wed, 26 Jan 2022 03:23:21 +0200 (EET) Received: by mail-pj1-f49.google.com with SMTP id h20-20020a17090adb9400b001b518bf99ffso3330914pjv.1 for ; Tue, 25 Jan 2022 17:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=qZT76qP6UrzX/jT1zMjWUk362XLOhE6rBCQ9xf8tTks=; b=osXtHHqn0vXRvkpee3FiroFUojuQ1fERyvpxnElUW+r+ebOoO8El45hlAYufyifl3w abO4aYLyF7Vu3xVA34MbVYmAfvF4LkI/8DcLHonvmksTBHgGWLwWYTr//pwtZghfIlvx uwqSu93PjtscGhG6QoSWNsDJ4QtOjyXQyHTeR7IELFTIJrTy4Dntug12UHN5FogkTaUE U3VGZMMfxiLgQgJRL6Qh2Zr1stgAbIc5ypg7KjBFoXbKox/Qj7d0hAAScfhbZSiv/Zn5 Y0y2ERReO29QrFBRyRKed8+oFs84QKWpsM2N3UajGYWs8mIuiD0Mr1xCXDAqWQUwev7/ BM3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=qZT76qP6UrzX/jT1zMjWUk362XLOhE6rBCQ9xf8tTks=; b=aFJUqGcKc4fwyToTS9Tu2HGtXSpjIc1Tv/YJIVF9GHZvXfro5+rlPE2ifvN4uIKELs HHzVJZMvJDdV4rjIEmgDphWLtQAGxk/bfH+gqAtcaDyaMV1VnaprIONxKe1NFm4V9deA CskwEln/uRC3iWqMSJ26CYVfHUw7q8d7O4oxytnZ6QjXZGwgNZCe2+Ye02dvfV6M0P+7 N4M7HlhU7Bk6JIqn0lqTQb30uFrTBNdYWwAh7LbvB5kcitAZnAlSyTe+nrTZ+dzz6UH5 1Rt5T+8tKwfVMJWVrnuzZ5ZSvZUz1jt7l0rrcF7FffH4qXkCIZG4lRkQhNP8UC993Vwt P/nw== X-Gm-Message-State: AOAM533Ib3WUJco3yTNBxakJkCExffKpAbFGjDm+mKfph0+XObcZwDFX Cc+mebt5qCtBQ7P0Hi5i1UIvvbsEsSY= X-Google-Smtp-Source: ABdhPJy6UKYj8FV7QgEAs45aiFKvIAcwJQiPIeH/pFAT7dGrrJGeTcXlHkMMTvTk1gouoKP+0v5Skw== X-Received: by 2002:a17:90a:f8b:: with SMTP id 11mr6335946pjz.130.1643160199111; Tue, 25 Jan 2022 17:23:19 -0800 (PST) Received: from gmail.com ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id f12sm4380480pgg.35.2022.01.25.17.23.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jan 2022 17:23:18 -0800 (PST) Date: Wed, 26 Jan 2022 09:23:15 +0800 From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Message-ID: <20220126012315.GA31182@gmail.com> Mail-Followup-To: ffmpeg-devel@ffmpeg.org References: <20220125072514.GA19401@gmail.com> <8e52c403-c58c-98d0-ccca-e5549c9d88ea@triularity.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <8e52c403-c58c-98d0-ccca-e5549c9d88ea@triularity.org> Subject: Re: [FFmpeg-devel] [PATCH] Fix setsockopt IP_MULTICAST_TTL on OpenBSD X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, Jan 25, 2022 at 04:28:33PM -0800, Chad Fraleigh wrote: > Since apparently linux will auto-detect (as mentioned by Marton Balint), based on the optlen parameter, just using unsigned char in all cases seems to be the cleanest. However, I would advise including a comment in the code to that effect which says to ignore the [outdated] linux documentation (so someone doesn't needlessly "correct" it in the future). > I agree with, use unsigned char is preferable for all system I think. > I looked at the kernel source and it does work both ways: > > static int do_ip_setsockopt(struct sock *sk, int level, int optname, > sockptr_t optval, unsigned int optlen) > { > ... > switch (optname) { > ... > case IP_MULTICAST_TTL: > ... > if (optlen >= sizeof(int)) { > if (copy_from_sockptr(&val, optval, sizeof(val))) > return -EFAULT; > } else if (optlen >= sizeof(char)) { > unsigned char ucval; > > if (copy_from_sockptr(&ucval, optval, sizeof(ucval))) > return -EFAULT; > val = (int) ucval; > } > } > ... > } > > This check has been in the kernel since at least 2.6.12-rc2 (from Apr 2005). It should work fine, unless newer ffmpeg builds support is needed on older systems. So the only question is how old are the kernels in IoT and android devices which might use the current ffmpeg? > > > On 1/24/2022 11:25 PM, lance.lmwang@gmail.com wrote: > > On Wed, Jan 12, 2022 at 12:13:13AM -0500, Brad Smith wrote: > >> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field > >> type should be an unsigned char on anything but Linux. > >> > >> > >> diff --git a/libavformat/udp.c b/libavformat/udp.c > >> index 180d96a988..29aa865fff 100644 > >> --- a/libavformat/udp.c > >> +++ b/libavformat/udp.c > >> @@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > >> { > >> #ifdef IP_MULTICAST_TTL > >> if (addr->sa_family == AF_INET) { > >> - if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { > >> +#ifdef __linux__ > >> + int ttl = mcastTTL; > >> +#else > >> + unsigned char ttl = mcastTTL; > >> +#endif > > > > > > I don't have BSD system for test, but I prefer to use socklen_t, please try with my proposal patch: > > > > --- > > libavformat/udp.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/udp.c b/libavformat/udp.c > > index 83c042d079..b9baa0a803 100644 > > --- a/libavformat/udp.c > > +++ b/libavformat/udp.c > > @@ -164,7 +164,9 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > > { > > #ifdef IP_MULTICAST_TTL > > if (addr->sa_family == AF_INET) { > > - if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { > > + socklen_t ttl = mcastTTL; > > + > > + if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) { > > ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); > > return ff_neterrno(); > > > > > >> + > >> + if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) { > >> ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); > >> return ff_neterrno(); > >> } > >> _______________________________________________ > >> ffmpeg-devel mailing list > >> ffmpeg-devel@ffmpeg.org > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > >> To unsubscribe, visit link above, or email > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".