Skip to contentSkip to conversation

env: add w flags for net config in explicit write mode

PATCH In review Heiko Schocher 2 participants 6 messages Jan 24 – Jan 26

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 env: add w flags for net config in explicit write mode

From: Adrian Freihofer <[email protected]>

In explicit write access mode (CONFIG_ENV_WRITEABLE_LIST) the environment variables listed in NET_FLAGS and NET6_FLAGS are probably intended to be writeable. Therefore add the 'w' flag to these variables.

---

 include/env_flags.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Azure build (patch is in a bunch of siemens patches sending now to mainline):
https://dev.azure.com/hs0298/hs/_build/results?buildId=202&view=results

include/env_flags.h +18 -0
index 0c48874690f..fc65dcaba21 100644
@@ -56,6 +56,16 @@ enum env_flags_varaccess {
 #define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mo,"
 #endif
 #endif
+#ifdef CONFIG_ENV_WRITEABLE_LIST
+#define NET_FLAGS \
+	"ipaddr:iw," \
+	"gatewayip:iw," \
+	"netmask:iw," \
+	"serverip:iw," \
+	"nvlan:dw," \
+	"vlan:dw," \
+	"dnsip:iw,"
+#else
 #define NET_FLAGS \
 	"ipaddr:i," \
 	"gatewayip:i," \
@@ -64,16 +74,24 @@ enum env_flags_varaccess {
 	"nvlan:d," \
 	"vlan:d," \
 	"dnsip:i,"
+#endif
 #else
 #define ETHADDR_FLAGS
 #define NET_FLAGS
 #endif
 
 #ifdef CONFIG_IPV6
+#ifdef CONFIG_ENV_WRITEABLE_LIST
+#define NET6_FLAGS \
+	"ip6addr:sw," \
+	"serverip6:sw," \
+	"gatewayip6:sw,"
+#else
 #define NET6_FLAGS \
 	"ip6addr:s," \
 	"serverip6:s," \
 	"gatewayip6:s,"
+#endif
 #else
 #define NET6_FLAGS
 #endif
Signature · 3 lines
2.20.1

base-commit: 6b2d05748cf3cd6ba417a96c00602b0122e10af6
#1 lore raw

Hello,

Quoted 6 lines · Heiko Schocher

From: Adrian Freihofer <[email protected]>

In explicit write access mode (CONFIG_ENV_WRITEABLE_LIST) the environment variables listed in NET_FLAGS and NET6_FLAGS are probably intended to be writeable. Therefore add the 'w' flag to these variables.

Users who enable CONFIG_ENV_WRITEABLE_LIST typically want full control over which environment variables are writable. The new default behavior introduced by your patch might not align with what all users expect or want.

Would overriding the flags using CFG_ENV_FLAGS_LIST_STATIC not work in this case?

Quoted 36 lines
include/env_flags.h +15 -0
index 0c48874690f..fc65dcaba21 100644
@@ -56,6 +56,16 @@ enum env_flags_varaccess {
 #define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mo,"
 #endif
 #endif
+#ifdef CONFIG_ENV_WRITEABLE_LIST
+#define NET_FLAGS \
+	"ipaddr:iw," \
+	"gatewayip:iw," \
+	"netmask:iw," \
+	"serverip:iw," \
+	"nvlan:dw," \
+	"vlan:dw," \
+	"dnsip:iw,"
+#else
 #define NET_FLAGS \
 	"ipaddr:i," \
 	"gatewayip:i," \
@@ -64,16 +74,24 @@ enum env_flags_varaccess {
 	"nvlan:d," \
 	"vlan:d," \
 	"dnsip:i,"
+#endif
 #else
 #define ETHADDR_FLAGS
 #define NET_FLAGS
 #endif
 
 #ifdef CONFIG_IPV6
+#ifdef CONFIG_ENV_WRITEABLE_LIST
+#define NET6_FLAGS \
+	"ip6addr:sw," \
+	"serverip6:sw," \

include/env_flags.h enum env_flags_varaccess { · line 97

Quoted 10 lines
include/env_flags.h +3 -0
+	"gatewayip6:sw,"
+#else
 #define NET6_FLAGS \
 	"ip6addr:s," \
 	"serverip6:s," \
 	"gatewayip6:s,"
+#endif
 #else
 #define NET6_FLAGS
 #endif

Best regards,

Signature · 3 lines
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

Hello Benjamin,

Quoted 10 lines · Benjamin ROBIN

Hello,

Quoted 6 lines · Heiko Schocher

From: Adrian Freihofer <[email protected]>

In explicit write access mode (CONFIG_ENV_WRITEABLE_LIST) the environment variables listed in NET_FLAGS and NET6_FLAGS are probably intended to be writeable. Therefore add the 'w' flag to these variables.

Quoted 6 lines

Users who enable CONFIG_ENV_WRITEABLE_LIST typically want full control over which environment variables are writable. The new default behavior introduced by your patch might not align with what all users expect or want.

Would overriding the flags using CFG_ENV_FLAGS_LIST_STATIC not work in this case?

Good question, I have to test... or may Adrian has already done such tests...

But looking into code.. if we add this variables in ENV_WRITEABLE_LIST the results would be, that this variables are twice in ENV_FLAGS_LIST_STATIC

include/env_flags.h
87 #define ENV_FLAGS_LIST_STATIC \

 88         ETHADDR_FLAGS \
 89         NET_FLAGS \
 90         NET6_FLAGS \
 91         SERIAL_FLAGS \
 92         CFG_ENV_FLAGS_LIST_STATIC

once through NET_FLAGS and once through CFG_ENV_FLAGS_LIST_STATIC

So, that is not good, and I think, code will find the first entry, and parse it -> so it will not work.

Should we instead in case CONFIG_ENV_WRITEABLE_LIST is enabled only set/allow CFG_ENV_FLAGS_LIST_STATIC in ENV_FLAGS_LIST_STATIC ?

bye,
Heiko

Signature · 5 lines
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschäftsführer : Stefano Babic
#3 lore raw

Hello Heiko,

Quoted 6 lines · Heiko Schocher
Quoted 6 lines

Users who enable CONFIG_ENV_WRITEABLE_LIST typically want full control over
which environment variables are writable. The new default behavior introduced by your patch might not align with what all users expect or want.

Quoted 6 lines
Quoted 3 lines

Would overriding the flags using CFG_ENV_FLAGS_LIST_STATIC not work in this
case?

Good question, I have to test... or may Adrian has already done such tests...

Please test.

Quoted 5 lines

But looking into code.. if we add this variables in ENV_WRITEABLE_LIST the results would be, that this variables are twice in ENV_FLAGS_LIST_STATIC

include/env_flags.h
87 #define ENV_FLAGS_LIST_STATIC \

Quoted 7 lines
  88         ETHADDR_FLAGS \
  89         NET_FLAGS \
  90         NET6_FLAGS \
  91         SERIAL_FLAGS \
  92         CFG_ENV_FLAGS_LIST_STATIC

once through NET_FLAGS and once through CFG_ENV_FLAGS_LIST_STATIC

Yes, the variables with the flags would be declared twice.

Quoted 2 lines

So, that is not good, and I think, code will find the first entry, and parse it -> so it will not work.

What leads you to this assumption?

If you examine the code, you'll notice that:
- The env_attr_lookup() function returns the last entry.
- When iterating over the flags using env_attr_walk(), any previous attribute flags are overridden by subsequent flag declarations.

Quoted 2 lines

Should we instead in case CONFIG_ENV_WRITEABLE_LIST is enabled only set/allow CFG_ENV_FLAGS_LIST_STATIC in ENV_FLAGS_LIST_STATIC ?

I haven't tested this myself, as I currently don't have a test environment available. Please test it, and if it doesn't work, the correct fix would be to ensure that any future flag declaration overrides previous ones.

Signature · 3 lines
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

Hello Benjamin,

Quoted 9 lines · Benjamin ROBIN

Hello Heiko,

Quoted 6 lines · Heiko Schocher
Quoted 6 lines

Users who enable CONFIG_ENV_WRITEABLE_LIST typically want full control over
which environment variables are writable. The new default behavior introduced by your patch might not align with what all users expect or want.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Would overriding the flags using CFG_ENV_FLAGS_LIST_STATIC not work in this
case?

Good question, I have to test... or may Adrian has already done such tests...

Please test.

We will do.

Quoted 19 lines
Quoted 5 lines

But looking into code.. if we add this variables in ENV_WRITEABLE_LIST the results would be, that this variables are twice in ENV_FLAGS_LIST_STATIC

include/env_flags.h

Quoted 8 lines
   87 #define ENV_FLAGS_LIST_STATIC \
   88         ETHADDR_FLAGS \
   89         NET_FLAGS \
   90         NET6_FLAGS \
   91         SERIAL_FLAGS \
   92         CFG_ENV_FLAGS_LIST_STATIC

once through NET_FLAGS and once through CFG_ENV_FLAGS_LIST_STATIC

Yes, the variables with the flags would be declared twice.

Quoted 2 lines

So, that is not good, and I think, code will find the first entry, and parse it -> so it will not work.

Quoted 6 lines

What leads you to this assumption?

If you examine the code, you'll notice that:
- The env_attr_lookup() function returns the last entry.
- When iterating over the flags using env_attr_walk(), any previous attribute flags are overridden by subsequent flag declarations.

Ah, thats the trick! If this is the case, I aggree, and we can simply drop this patch!

Quoted 7 lines
Quoted 3 lines

Should we instead in case CONFIG_ENV_WRITEABLE_LIST is enabled only set/allow CFG_ENV_FLAGS_LIST_STATIC in ENV_FLAGS_LIST_STATIC ?

I haven't tested this myself, as I currently don't have a test environment available. Please test it, and if it doesn't work, the correct fix would be to ensure that any future flag declaration overrides previous ones.

We will test, thanks!

bye,
Heiko

Signature · 5 lines
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschäftsführer : Stefano Babic
#5 lore raw

Hello Benjamin

Quoted 52 lines · Heiko Schocher

Hello Benjamin,

Quoted 9 lines · Benjamin ROBIN

Hello Heiko,

Quoted 6 lines · Heiko Schocher
Quoted 6 lines

Users who enable CONFIG_ENV_WRITEABLE_LIST typically want full control over
which environment variables are writable. The new default behavior introduced by your patch might not align with what all users expect or want.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Would overriding the flags using CFG_ENV_FLAGS_LIST_STATIC not work in this
case?

Good question, I have to test... or may Adrian has already done such tests...

Please test.

We will do.

Quoted 18 lines
Quoted 12 lines

But looking into code.. if we add this variables in ENV_WRITEABLE_LIST the results would be, that this variables are twice in ENV_FLAGS_LIST_STATIC

include/env_flags.h
   87 #define ENV_FLAGS_LIST_STATIC \
   88         ETHADDR_FLAGS \
   89         NET_FLAGS \
   90         NET6_FLAGS \
   91         SERIAL_FLAGS \
   92         CFG_ENV_FLAGS_LIST_STATIC

Quoted 1 line

once through NET_FLAGS and once through CFG_ENV_FLAGS_LIST_STATIC

Yes, the variables with the flags would be declared twice.

Quoted 2 lines

So, that is not good, and I think, code will find the first entry, and parse it -> so it will not work.

Quoted 6 lines

What leads you to this assumption?

If you examine the code, you'll notice that:
  - The env_attr_lookup() function returns the last entry.
  - When iterating over the flags using env_attr_walk(), any previous attribute flags are overridden by subsequent flag declarations.

Ah, thats the trick! If this is the case, I aggree, and we can simply drop this patch!

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Should we instead in case CONFIG_ENV_WRITEABLE_LIST is enabled only set/allow CFG_ENV_FLAGS_LIST_STATIC in ENV_FLAGS_LIST_STATIC ?

I haven't tested this myself, as I currently don't have a test environment available. Please test it, and if it doesn't work, the correct fix would be to ensure that any future flag declaration overrides previous ones.

We will test, thanks!

Thanks for this hint, we tested your suggestion and it works!

So this patch can be ignored, I already changed the state in patchwork to superseded!

Thanks!

bye,
Heiko

Quoted 3 lines

bye,
Heiko

Signature · 5 lines
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschäftsführer : Stefano Babic