Skip to contentSkip to conversation

Two fixes related to '--concurrent'.

PATCH Superseded Firo Yang 3 participants 12 messages Apr 1, 2021 – Apr 6, 2021 2 messages not in the archive netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Firo Yang

author
#0 lore raw

cover Two fixes related to '--concurrent'.

Fixed two problems related to '--concurrent'.

Firo Yang (2):
ebtables: processing '--concurrent' beofore other arguments
libebtc: Fix an issue that '--concurrent' doesn't work with NFS

 ebtables.c | 22 +++++++++++++++++++---
 libebtc.c  |  2 +-
 2 files changed, 20 insertions(+), 4 deletions(-)

base-commit: 46eb78ff358724f5addf14e45f2cfc31542ede3c

Signature · 1 line
2.30.2
author
#1 lore raw

PATCH 1/2 ebtables: processing '--concurrent' beofore other arguments

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

---
 ebtables.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
ebtables.c +19 -3
index f7dfccf..98f655b 100644
@@ -98,6 +98,12 @@ static struct option ebt_original_options[] =
 
 static struct option *ebt_options = ebt_original_options;
 
+static struct option ebt_global_options[] =
+{
+        { "concurrent"     , no_argument      , 0, 13  },
+        { 0 }
+};
+
 /* Holds all the data */
 static struct ebt_u_replace *replace;
 
@@ -580,6 +586,17 @@ int do_command(int argc, char *argv[], int exec_style,
 	 * '-t'  ,'-M' and --atomic (if specified) have to come
 	 * before '-A' and the like */
 
+	while ((c = getopt_long(argc, argv, "", ebt_global_options, NULL)) != -1) {
+		switch (c) {
+		case 13 : /* concurrent */
+                        use_lockfd = 1;
+                        break;
+                default :
+                        continue;
+                }
+        }
+
+        optind = 1;
 	/* Getopt saves the day */
 	while ((c = getopt_long(argc, argv,
 	   "-A:D:C:I:N:E:X::L::Z::F::P:Vhi:o:j:c:p:s:d:t:M:", ebt_options, NULL)) != -1) {
@@ -1040,9 +1057,8 @@ big_iface_length:
 			replace->filename = (char *)malloc(strlen(optarg) + 1);
 			strcpy(replace->filename, optarg);
 			break;
-		case 13 : /* concurrent */
-			use_lockfd = 1;
-			break;
+		case 13 :
+			continue;
 		case 1 :
 			if (!strcmp(optarg, "!"))
 				ebt_check_inverse2(optarg);
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

--concurrent has never worked unless you place it in first place anyway.

#3 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 9 lines · Pablo Neira Ayuso

Hi,

Quoted 6 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

Quoted 4 lines
Quoted 1 line

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Quoted 2 lines

--concurrent has never worked unless you place it in first place anyway.

author
#4 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 12 lines · Pablo Neira Ayuso
Quoted 11 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Quoted 7 lines
Quoted 2 lines

Would you instead make a patch to spew an error if --concurrent is the first argument?

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

--
Firo

Quoted 4 lines
Quoted 3 lines

--concurrent has never worked unless you place it in first place anyway.

#5 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 16 lines · Firo Yang
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Quoted 8 lines
Quoted 4 lines

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

See ebtables.c line 579.

/* The scenario induced by this loop makes that:
* '-t' ,'-M' and --atomic (if specified) have to come
* before '-A' and the like */

There are other options following this approach, please align --concurrent with those.

Have a look at 'M' and 't' for the error that is reported.

                case 'M': /* Modprobe */
                        if (OPT_COMMANDS)
                                ebt_print_error2("Please put the -M option earlier");

Thanks.

A message that is not in the archive (sent off-list or not yet received): 6cc20464d5814fe899d7fb1e21d5488c@DB8PR04MB5881.eurprd04.prod.outlook.com

#7 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 16 lines · Firo Yang
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Quoted 8 lines
Quoted 4 lines

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

Agreed, that also wouldn't be seen as a workable solution for us "SUSE" as our customers who may have scripts or documented processes where --concurrent is not first and such a change would be considered a "Change in behavior" as such we can't ship it in a bugfix or minor version update, only in the next major update and we don't know when that will be yet.

Sure this is probably only a issue for enterprise distro's but such a change would likely inconvenience other users as well.

Cheers

Signature · 5 lines
Simon Lees (Simotek)                            http://simotek.net

Emergency Update Team                           keybase.io/simotek
SUSE Linux                           Adelaide Australia, UTC+10:30
GPG Fingerprint: 5B87 DB9D 88DC F606 E489 CEC5 0922 C246 02F0 014B
#8 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Hi,

Quoted 35 lines · Simon Lees
Quoted 16 lines · Firo Yang
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Quoted 8 lines
Quoted 4 lines

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

Agreed, that also wouldn't be seen as a workable solution for us "SUSE" as our customers who may have scripts or documented processes where --concurrent is not first and such a change would be considered a "Change in behavior" as such we can't ship it in a bugfix or minor version update, only in the next major update and we don't know when that will be yet.

Quoted 2 lines

Sure this is probably only a issue for enterprise distro's but such a change would likely inconvenience other users as well.

--concurrent has never worked away from the early positions ever.

What's the issue?

A message that is not in the archive (sent off-list or not yet received): 64466cd69b054f5d803722dfbcf8c4be@DB8PR04MB5881.eurprd04.prod.outlook.com

#10 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 38 lines · Pablo Neira Ayuso

Hi,

Quoted 35 lines · Simon Lees
Quoted 16 lines · Firo Yang
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Quoted 8 lines
Quoted 4 lines

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

Agreed, that also wouldn't be seen as a workable solution for us "SUSE" as our customers who may have scripts or documented processes where --concurrent is not first and such a change would be considered a "Change in behavior" as such we can't ship it in a bugfix or minor version update, only in the next major update and we don't know when that will be yet.

Quoted 6 lines
Quoted 2 lines

Sure this is probably only a issue for enterprise distro's but such a change would likely inconvenience other users as well.

--concurrent has never worked away from the early positions ever.

What's the issue?

We had a customer complaining about the change in ordering causing different results with one way working and the other not, looking back at the report a second time I don't think they were ever using the "non working way" in production but just to debug the other issue.

Signature · 5 lines
Simon Lees (Simotek)                            http://simotek.net

Emergency Update Team                           keybase.io/simotek
SUSE Linux                           Adelaide Australia, UTC+10:30
GPG Fingerprint: 5B87 DB9D 88DC F606 E489 CEC5 0922 C246 02F0 014B
#11 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 44 lines · Simon Lees
Quoted 41 lines · Pablo Neira Ayuso

Hi,

Quoted 37 lines · Simon Lees
Quoted 16 lines · Firo Yang
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Quoted 8 lines
Quoted 4 lines

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

Agreed, that also wouldn't be seen as a workable solution for us "SUSE" as our customers who may have scripts or documented processes where --concurrent is not first and such a change would be considered a "Change in behavior" as such we can't ship it in a bugfix or minor version update, only in the next major update and we don't know when that will be yet.

Sure this is probably only a issue for enterprise distro's but such a change would likely inconvenience other users as well.

Quoted 8 lines
Quoted 3 lines

--concurrent has never worked away from the early positions ever.

What's the issue?

We had a customer complaining about the change in ordering causing different results with one way working and the other not, looking back at the report a second time I don't think they were ever using the "non working way" in production but just to debug the other issue.

Thanks for explaining, then I think we can go for the "restrict position" fix which aligns with the -M, -t, ..., correct?

author
#12 lore raw

Re: [PATCH 1/2] ebtables: processing '--concurrent' beofore other arguments

Quoted 49 lines · Pablo Neira Ayuso
Quoted 48 lines · Simon Lees
Quoted 44 lines · Pablo Neira Ayuso

Hi,

Quoted 35 lines · Simon Lees
Quoted 16 lines · Firo Yang
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · Pablo Neira Ayuso

Hi,

Quoted 7 lines · Firo Yang

Our customer reported a following issue:
If '--concurrent' was passed to ebtables command behind other arguments, '--concurrent' will not take effect sometimes; for a simple example, ebtables -L --concurrent. This is becuase the handling of '--concurrent' is implemented in a passing-order-dependent way.

So we can fix this problem by processing it before other arguments.

Would you instead make a patch to spew an error if --concurrent is the first argument?

Quoted 8 lines
Quoted 4 lines

Wrong wording:

Would you instead make a patch to spew an error if --concurrent is _not_ the first argument?

Hi Pablo, I think it would make more sense if we don't introduce this inconvenice to users. If you insist, I would go create the patch as you intended.

Agreed, that also wouldn't be seen as a workable solution for us "SUSE" as our customers who may have scripts or documented processes where --concurrent is not first and such a change would be considered a "Change in behavior" as such we can't ship it in a bugfix or minor version update, only in the next major update and we don't know when that will be yet.

Quoted 2 lines

Sure this is probably only a issue for enterprise distro's but such a change would likely inconvenience other users as well.

--concurrent has never worked away from the early positions ever.

What's the issue?

Quoted 7 lines
Quoted 4 lines

We had a customer complaining about the change in ordering causing different results with one way working and the other not, looking back at the report a second time I don't think they were ever using the "non working way" in production but just to debug the other issue.

Thanks for explaining, then I think we can go for the "restrict position" fix which aligns with the -M, -t, ..., correct?

Hi Pablo,

To be frank, I think the 'restrict position' manner is really unfriendly to users, which put burden on them to learn and remember this kind of rare and unique usage. I could create a bigger patch to change other arugments '-M', '-t' along with '--concurrent'. Does this sound good to you?

--
Firo

author
#13 lore raw

PATCH 2/2 libebtc: Fix an issue that '--concurrent' doesn't work with NFS

In reply to Firo Yang

Due to the following commit[1] from kernel, if '/var/lib/ebtables' was mounted with a NFS filesystem, ebtables command will hit the following error:
mount | grep nfs
x.x.x.x:/var/lib/ebtables on /var/lib/ebtables type nfs4 [...] /usr/sbin/ebtables --concurrent -L
Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock
[...]

In order to fix this problem, add 'O_WRONLY' to match the requirement of that kernel commit[1].

[1]: 55725513b5ef ("NFSv4: Ensure that we check lock exclusive/shared type against open modes")

---
 libebtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libebtc.c +1 -1
index 1b058ef..112c307 100644
@@ -144,7 +144,7 @@ static int lock_file()
 	int fd, try = 0;
 
 retry:
-	fd = open(LOCKFILE, O_CREAT|O_CLOEXEC, 00600);
+	fd = open(LOCKFILE, O_CREAT|O_WRONLY|O_CLOEXEC, 00600);
 	if (fd < 0) {
 		if (try == 1 || mkdir(dirname(pathbuf), 00700))
 			return -2;
Signature · 1 line
2.30.2