# Fw4 and hotplug

**URL:** <https://forum.openwrt.org/t/fw4-and-hotplug/150794>\
**Category:** Installing and Using OpenWrt\
**Created:** [February 6, 2023, 7:38pm UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794 "2023-02-06T19:38:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rod](https://forum.openwrt.org/letter_avatar/rod/32/5_5575768a8748004e209b776fc1b2916d.png) [@Rod](https://forum.openwrt.org/u/Rod)\
**Post date:** [February 6, 2023, 7:38pm UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/1 "2023-02-06T19:38:03Z")

</div>

Does fw4 "publish" events to hotplug like fw3 does?

In 21.02.x, fw3 apparently calls /sbin/hotplug-call.

In 22.03.3 I couldn't find anything similar for fw4.  
Furthermore, the suggested test on  
[hotplug](https://openwrt.org/docs/guide-user/base-system/hotplug#usagetroubleshooting) produces nothing with fw4. It works with fw3.

---

<div class="post-metadata">

**Author:** ![Rod](https://forum.openwrt.org/letter_avatar/rod/32/5_5575768a8748004e209b776fc1b2916d.png) [@Rod](https://forum.openwrt.org/u/Rod)\
**Post date:** [February 7, 2023, 12:25am UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/2 "2023-02-07T00:25:26Z")

</div>

Tried to get the events with:

ubus subscribe service

But got nothing when doing service firewall (reload/restart)

Maybe this should be better placed in the 'For Developers' category, not sure.

---

<div class="post-metadata">

**Author:** ![stangri](https://forum.openwrt.org/user_avatar/forum.openwrt.org/stangri/32/58_2.png) [@stangri](https://forum.openwrt.org/u/stangri)\
**Post date:** [February 7, 2023, 4:41am UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/3 "2023-02-07T04:41:42Z")

</div>

Not obvious what you're trying to accomplish, but either or both of the two options may be of use:

1. Place custom scripts into `/usr/share/nftables.d` (check the README in there for usage)
2. Create a fw4-compatible include file and edit firewall config, like this:

```plaintext
config include 'pbr'
	option fw4_compatible '1'
	option type 'script'
	option path '/usr/share/pbr/pbr.firewall.include'

```

---

<div class="post-metadata">

**Author:** ![Rod](https://forum.openwrt.org/letter_avatar/rod/32/5_5575768a8748004e209b776fc1b2916d.png) [@Rod](https://forum.openwrt.org/u/Rod)\
**Post date:** [February 7, 2023, 5:21am UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/4 "2023-02-07T05:21:32Z")

</div>

Hey, thanks for the suggestions.

I admit I didn't provide any detail on the intent, because I don't need help with that.  
Just need to know if it is intentional that fw4 doesn't "publish" events to hotplug, like fw3 does.

Looking at a default v22.03.3 image, there are subfolders in /etc/hotplug.d for dhcp, net, iface, etc but not for firewall. So, it looks like that is the case; but looking for an "official" confirmation that this changed with fw4/v22.03.x and onwards.

---

<div class="post-metadata">

**Author:** ![RuralRoots](https://forum.openwrt.org/letter_avatar/ruralroots/32/5_5575768a8748004e209b776fc1b2916d.png) [@RuralRoots](https://forum.openwrt.org/u/RuralRoots)\
**Post date:** [February 10, 2023, 7:46am UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/5 "2023-02-10T07:46:21Z")

</div>

> [@Rod](#):
>
> Does fw4 "publish" events to hotplug like fw3 does?

> [@Rod](#):
>
> Just need to know if it is intentional that fw4 doesn't "publish" events to hotplug, like fw3 does.

I am not clear about the meaning of " **events** `fw3` **publishes to hotplug**"?

> [@Rod](#):
>
> In 21.02.x, fw3 apparently calls /sbin/hotplug-call.

Hotplug works with `procd` (process management daemon). When `procd` detects a _trigger event_, it just calls all scripts in the _trigger event_ directory in alpha order.

`/sbin/hotplug-call` is a helper script that ensures the `procd` _trigger event_ is pointed to the correct directory in `/etc/hotplug.d`

You can find other packages that utilize it here: [https://github.com/openwrt/packages/search?p=1&q=hotplug-call](https://github.com/openwrt/packages/search?p=1&q=hotplug-call)

> [@Rod](#):
>
> Looking at a default v22.03.3 image, there are subfolders in /etc/hotplug.d for dhcp, net, iface, etc but not for firewall. So, it looks like that is the case; but looking for an "official" confirmation that this changed with fw4/v22.03.x and onwards.

FWIW, I don't have any entries in `/etc/hotplug.d/firewall` in 21.02.3/5 or Master Snapshot, at least not since I stopped using `vpn-policy-routing`.

> [@](#):
>
> Furthermore, the suggested test on  
> '[https://openwrt.org/docs/guide-user/base-system/hotplug#usagetroubleshooting](https://openwrt.org/docs/guide-user/base-system/hotplug#usagetroubleshooting)'  
> produces nothing with fw4. It works with fw3.

Well, if you are looking for the environment variables used in each _hotplug directory_ you could add something like this to each of the **Trigger Directories** - **block/button/dhcp/dsl/firewall/iface/neigh/net/tftp/usb** :

```plaintext
cat << "EOF" > /etc/hotplug.d/<trigger directory>/00-logger
logger -t PROCD-<Trigger Dir> $(env) > /var/log/procd/procd_<Trigger Dir>
EOF

```

This will log every possible trigger whenever the system triggers the event.

---

<div class="post-metadata">

**Author:** ![jow](https://forum.openwrt.org/user_avatar/forum.openwrt.org/jow/32/13_2.png) [@jow](https://forum.openwrt.org/u/jow)\
**Post date:** [February 10, 2023, 8:09am UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/6 "2023-02-10T08:09:35Z")

</div>

> [@Rod](#):
>
> Just need to know if it is intentional that fw4 doesn't "publish" events to hotplug, like fw3 does.

Yes, this is intentional. The current fw4 implementation does not emit firewall hotplug events.

---

<div class="post-metadata">

**Author:** ![Rod](https://forum.openwrt.org/letter_avatar/rod/32/5_5575768a8748004e209b776fc1b2916d.png) [@Rod](https://forum.openwrt.org/u/Rod)\
**Post date:** [February 10, 2023, 1:07pm UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/7 "2023-02-10T13:07:56Z")

</div>

> [@RuralRoots](#):
>
> Hotplug works with `procd` (process management daemon). When `procd` detects a _trigger event_, it just calls all scripts in the _trigger event_ directory in alpha order.

Well, fw4 doesn't _trigger_ any event. Fw3 does.

> [@RuralRoots](#):
>
> > [@](#):
> >
> > Furthermore, the suggested test on  
> > '[https://openwrt.org/docs/guide-user/base-system/hotplug#usagetroubleshooting](https://openwrt.org/docs/guide-user/base-system/hotplug#usagetroubleshooting)'  
> > produces nothing with fw4. It works with fw3.
> 
> Well, if you are looking for the environment variables used in each _hotplug directory_ you could add something like this to each of the **Trigger Directories** - **block/button/dhcp/dsl/firewall/iface/neigh/net/tftp/usb** :
> 
> ```plaintext
> cat << "EOF" > /etc/hotplug.d/<trigger directory>/00-logger
> logger -t PROCD-<Trigger Dir> $(env) > /var/log/procd/procd_<Trigger Dir>
> EOF
> 
> ```
> 
> This will log every possible trigger whenever the system triggers the event.

As noted on my post, already did that but not looking for the environment variables used in each _hotplug directory_. Instead looking to confirm if fw4 doesn't _trigger_ any event by design OR because of a bug.

Got the answer: [#6](https://forum.openwrt.org/t/fw4-and-hotplug/150794/6)  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://forum.openwrt.org/uploads/default/original/3X/7/4/740520c71f00039bbf001045c682f0ecb25e905a.png) [@system](https://forum.openwrt.org/u/system)\
**Post date:** [February 20, 2023, 1:08pm UTC](https://forum.openwrt.org/t/fw4-and-hotplug/150794/8 "2023-02-20T13:08:33Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
