From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZMHP9LGp; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 35D975A061B for ; Mon, 25 Nov 2024 09:30:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732523422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xpv9Km6E1E69v5VeDtAnGG7fYpPjWrrH3RU0vlnEPkI=; b=ZMHP9LGplp0QN5a2EkGx4wSTSz/Ml66yUweH6P02N6jQH2AOoD1v7FXK1ZACciCHWxdpSR XBbuvth4OXBt3fOzVZOKytiTeHp7vD1bJXzxkOeXwxBH+xEpNSJiY21cpmZpeppjQzRpL9 MCHv71iFLJ7LvUHJW4VfNbKMdF8sCX8= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-340-Jtnv0Dk_NZa8EF63qxsUeA-1; Mon, 25 Nov 2024 03:30:19 -0500 X-MC-Unique: Jtnv0Dk_NZa8EF63qxsUeA-1 X-Mimecast-MFC-AGG-ID: Jtnv0Dk_NZa8EF63qxsUeA Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-38249bf9e82so2120644f8f.2 for ; Mon, 25 Nov 2024 00:30:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732523417; x=1733128217; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Xpv9Km6E1E69v5VeDtAnGG7fYpPjWrrH3RU0vlnEPkI=; b=DBZKEy23KjkTOoHlnBuaFa3dPSTgWGWZ/Vy1TuphuG0K42/OXBMKp4eRiI7VbsKpnQ wZHx8EZjaiquskoV1KdIJEyRDuAAqCoW0IYV/L8XqiGr+699CdS+q8EL7rsXie1muewP p1mufth2cre+RTUkWd2aik4JwnF/FcQ2hGgp+bwh/pCz7EeH+rpFM4BhqXxXkNbna7UK hcBQNWv4ozAU37hw3QWaklzn/85T2aD/oiri0QHjH7rFr0VseTRcNC3044ey5aB9Q01s oV32veSjIu1Nw9JlqDTFUz79AvcxaXHSjJtKryhNQYIYoX0o/nAA8UeR85gyPxHxxI3H X8Ew== X-Gm-Message-State: AOJu0YzrrQubEyl4DHZkBj9MGoKKtNDGgvJXtSjmOjKiTEymd89E3MMK Vi1WEc7J4AMLKZYRvPlo4w10mm4H9Z2IonC2kLUgXCovn5VLz5Pe4Fjld3kaUNzP5/Bie0vLsX2 w+I9OscZkLONW7HMkdgqFqfhU3//R2FBjFCCze7ykQCy57ed3hnVFL64Ogg== X-Gm-Gg: ASbGncvFZz6+r+XSZ3agM8px+EaYcYYkgd/DbcCFhRigzvNkf82EXy1dm/INxnYxmzv 6qW38XQcX2VBYcEznsX9I0EjF4wl4BaOPUZ98kKfQq4YmtBWXmUy9Erej7MIql0QL246UVWS49y eyAwCAu8d8Leub3OE9ilBi6sngqvbcU+dFpNsUXGZAh1bLPb74270fBRpfW6GUln6LDsUlm/vZi PXfrOYYG6O5lESPjN9D9RrzQ98edQ7lOhb2lFTz0WtacQv1mai4WX+VVb5+rSVJxz6sXG6QTW0r kMA= X-Received: by 2002:a05:6000:1f8c:b0:382:4378:462a with SMTP id ffacd0b85a97d-38260b759c0mr9670438f8f.24.1732523417512; Mon, 25 Nov 2024 00:30:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJxvqdW2l/+I1lRIsP27uS5ICcITeM0riWwXWHvE7gLVN66FCpu21Ayu1/ygGoHMlLfXip2Q== X-Received: by 2002:a05:6000:1f8c:b0:382:4378:462a with SMTP id ffacd0b85a97d-38260b759c0mr9670414f8f.24.1732523417153; Mon, 25 Nov 2024 00:30:17 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825faff9cdsm9708249f8f.28.2024.11.25.00.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 00:30:16 -0800 (PST) Date: Mon, 25 Nov 2024 09:30:15 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 3/3] dhcp: Honour broadcast flag (RFC 2131, 4.1) Message-ID: <20241125093015.6e91899b@elisabeth> In-Reply-To: References: <20241125000423.4131458-1-sbrivio@redhat.com> <20241125000423.4131458-4-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: VQkbnbRQjOCLb2WVViIfdJewsUToQgumPnsuXtZtrpM_1732523418 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: LZUVFTVVVFVKZVAWRE46N6KLJFSZPT33 X-Message-ID-Hash: LZUVFTVVVFVKZVAWRE46N6KLJFSZPT33 X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon, 25 Nov 2024 12:11:34 +1100 David Gibson wrote: > On Mon, Nov 25, 2024 at 01:04:23AM +0100, Stefano Brivio wrote: > > It's widely considered a legacy option nowadays, and I've haven't seen > > clients setting it since Windows 95, but it's convenient for a minimal > > DHCP client not using raw IP sockets such as what I'm playing with for > > muvm. > > > > Signed-off-by: Stefano Brivio > > --- > > dhcp.c | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/dhcp.c b/dhcp.c > > index aa0ad96..f1416ee 100644 > > --- a/dhcp.c > > +++ b/dhcp.c > > @@ -107,6 +107,8 @@ struct msg { > > uint32_t xid; > > uint16_t secs; > > uint16_t flags; > > +#define FLAG_BROADCAST htons_constant(0x8000) > > + > > uint32_t ciaddr; > > struct in_addr yiaddr; > > uint32_t siaddr; > > @@ -280,10 +282,10 @@ int dhcp(const struct ctx *c, const struct pool *p) > > { > > size_t mlen, dlen, offset = 0, opt_len, opt_off = 0; > > char macstr[ETH_ADDRSTRLEN]; > > + struct in_addr mask, dst; > > const struct ethhdr *eh; > > const struct iphdr *iph; > > const struct udphdr *uh; > > - struct in_addr mask; > > unsigned int i; > > struct msg *m; > > > > @@ -398,7 +400,13 @@ int dhcp(const struct ctx *c, const struct pool *p) > > opt_set_dns_search(c, sizeof(m->o)); > > > > dlen = offsetof(struct msg, o) + fill(m); > > - tap_udp4_send(c, c->ip4.our_tap_addr, 67, c->ip4.addr, 68, m, dlen); > > + > > + if (m->flags & FLAG_BROADCAST) > > + dst = (struct in_addr){ 0xffffffff }; > > It would be nice to add a symbolic constant ("in4addr_broadcast"?) to > ip.h for this. Sure, added as in4addr_broadcast. > > + else > > + dst = c->ip4.addr; > > + > > + tap_udp4_send(c, c->ip4.our_tap_addr, 67, dst, 68, m, dlen); > > > > return 1; > > } -- Stefano