From nobody Tue Jul 19 20:02:40 2022 X-Original-To: freebsd-pf@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LnVB0458Lz4WwJ7 for ; Tue, 19 Jul 2022 20:02:48 +0000 (UTC) (envelope-from mike@sentex.net) Received: from smarthost1.sentex.ca (smarthost1.sentex.ca [IPv6:2607:f3e0:0:1::12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smarthost1.sentex.ca", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LnV9z2Q6gz4MVF for ; Tue, 19 Jul 2022 20:02:47 +0000 (UTC) (envelope-from mike@sentex.net) Received: from pyroxene2a.sentex.ca (pyroxene19.sentex.ca [199.212.134.19]) by smarthost1.sentex.ca (8.16.1/8.16.1) with ESMTPS id 26JK2e6t083501 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 19 Jul 2022 16:02:40 -0400 (EDT) (envelope-from mike@sentex.net) Received: from [IPV6:2607:f3e0:0:4:5933:dca:7616:52ec] ([IPv6:2607:f3e0:0:4:5933:dca:7616:52ec]) by pyroxene2a.sentex.ca (8.16.1/8.15.2) with ESMTPS id 26JK2d1G045044 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO) for ; Tue, 19 Jul 2022 16:02:40 -0400 (EDT) (envelope-from mike@sentex.net) Message-ID: <7126c3de-2eab-733a-863d-0a38c409919e@sentex.net> Date: Tue, 19 Jul 2022 16:02:40 -0400 List-Id: Technical discussion and general questions about packet filter (pf) List-Archive: https://lists.freebsd.org/archives/freebsd-pf List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-pf@freebsd.org X-BeenThere: freebsd-pf@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.2 Content-Language: en-US To: "freebsd-pf@freebsd.org" From: mike tancsa Subject: updating "self" in RELENG_13 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 64.7.153.18 X-Rspamd-Queue-Id: 4LnV9z2Q6gz4MVF X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mike@sentex.net designates 2607:f3e0:0:1::12 as permitted sender) smtp.mailfrom=mike@sentex.net X-Spamd-Result: default: False [-3.40 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_ALLOW(-0.20)[+ip6:2607:f3e0::/32]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[199.212.134.19:received]; FROM_HAS_DN(0.00)[]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-pf@freebsd.org]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:11647, ipnet:2607:f3e0::/32, country:CA]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_EQ_ADDR_ALL(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; PREVIOUSLY_DELIVERED(0.00)[freebsd-pf@freebsd.org]; FREEFALL_USER(0.00)[mike]; DMARC_NA(0.00)[sentex.net]; MID_RHS_MATCH_FROM(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[] X-ThisMailContainsUnwantedMimeParts: N I have an endpoint where interfaces come and go or change IP addresses due to dynamic IPs being handed out.  One thing I noticed is that if I want to make use of the "self" keyword, the automatic table that it abstracts away does not get automatically updated with new IP addresses.  If I manually do a pfctl -f /etc/pf.conf, it fixes the issue.  So to automate it, I looked at devd to create % cat /etc/devd/interface.conf notify 0 {     match "system"        "IFNET";     match "type"          "(LINK_DOWN|LINK_UP)";     action "/usr/local/bin/interface-change.sh $subsystem $interface"; }; and in the script I call /sbin/pfctl -f /etc/pf.conf But the next issue I ran into is the interface often comes up before its given an IP. So to make it work I had to add a sleep 5 ; /sbin/pfctl -f /etc/pf.conf & Not really happy with this method as sleeps are a bit hackish and probably wont reliably work.  Anyone else run into this issue and how do you work around it ? Or am I approaching it the wrong way ? I also noticed that if I do something like  ifconfig lo0 192.168.99.2/32 alias devd does not fire     ---Mike