Skip to contentSkip to conversation

rtnetlink: ndo_dflt_fdb_del() never works

PATCH In review Alan Robertson 3 participants 7 messages May 30, 2013 – Jun 3, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtnetlink: ndo_dflt_fdb_del() never works

ndo_dflt_fdb_del is checking for a condition which is opposite that which ndo_dflt_fdb_add enforces. ndo_dflt_fdb_add declares an error if (ndm->ndm_state && !(ndm->ndm_state) & NUD_PERMANENT)) - that is, if the entry is static. This is consistent with the failure error message.

On the other hand, ndo_dflt_del() declares an error
if (ndm_state & NUD_PERMANENT) - which is inconsistent with the add precondition, and inconsistent with its failure message text. As it is now, you can't delete any entry which add allows to be added - so entry deletion always fails.

---
 net/core/rtnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/rtnetlink.c +1 -1
index a08bd2b..373a8e7 100644
@@ -2142,7 +2142,7 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm,
 	/* If aging addresses are supported device will need to
 	 * implement its own handler for this.
 	 */
-	if (ndm->ndm_state & NUD_PERMANENT) {
+	if (!(ndm->ndm_state & NUD_PERMANENT)) {
 		pr_info("%s: FDB only supports static addresses\n", dev->name);
 		return -EINVAL;
 	}
Signature · 1 line
1.8.1.4
maintainer
#1 lore raw

From: Alan Robertson <[email protected]>
Date: Thu, 30 May 2013 16:01:55 -0600

Quoted 5 lines

ndo_dflt_fdb_del is checking for a condition which is opposite that which ndo_dflt_fdb_add enforces. ndo_dflt_fdb_add declares an error if (ndm->ndm_state && !(ndm->ndm_state) & NUD_PERMANENT)) - that is, if the entry is static. This is consistent with the failure error message.

Quoted 7 lines

On the other hand, ndo_dflt_del() declares an error
if (ndm_state & NUD_PERMANENT) - which is inconsistent with the add precondition, and inconsistent with its failure message text. As it is now, you can't delete any entry which add allows to be added - so entry deletion always fails.

What about the ->ndm_state part of the add() test? Why not include that in the del() check?

#2 lore raw
Quoted 14 lines · David Miller

From: Alan Robertson <[email protected]>
Date: Thu, 30 May 2013 16:01:55 -0600

Quoted 11 lines

ndo_dflt_fdb_del is checking for a condition which is opposite that which ndo_dflt_fdb_add enforces. ndo_dflt_fdb_add declares an error if (ndm->ndm_state && !(ndm->ndm_state) & NUD_PERMANENT)) - that is, if the entry is static. This is consistent with the failure error message.

On the other hand, ndo_dflt_del() declares an error
if (ndm_state & NUD_PERMANENT) - which is inconsistent with the add precondition, and inconsistent with its failure message text. As it is now, you can't delete any entry which add allows to be added - so entry deletion always fails.

Quoted 3 lines
Quoted 1 line

What about the ->ndm_state part of the add() test? Why not include that in the del() check?

I had three different thoughts about this:
1) Replicated the add check in the delete
2) Do what I did - make it where you can only delete those really
marked as static
3) Eliminate all delete checks

The problem is -- I'm not sure why the ndm->ndm_state check is in there -- I don't know how to make that condition occur. It has the feel of a check to be made before things are fully initialized - or maybe even just leftover cruft.

You could make the argument that option (3) is the best -- if it's been added successfully, you ought to be able to delete it.

If someone with more knowledge would comment that would be much appreciated!

I'm happy to submit any of these three versions of the patch. Let me know what's wanted.

Signature · 3 lines
    Alan Robertson <[email protected]> - @OSSAlanR

"Openness is the foundation and preservative of friendship...  Let me claim from you at all times your undisguised opinions." - William Wilberforce
#3 lore raw
Quoted 24 lines · Alan Robertson
Quoted 14 lines · David Miller

From: Alan Robertson <[email protected]>
Date: Thu, 30 May 2013 16:01:55 -0600

Quoted 11 lines

ndo_dflt_fdb_del is checking for a condition which is opposite that which ndo_dflt_fdb_add enforces. ndo_dflt_fdb_add declares an error if (ndm->ndm_state && !(ndm->ndm_state) & NUD_PERMANENT)) - that is, if the entry is static. This is consistent with the failure error message.

On the other hand, ndo_dflt_del() declares an error
if (ndm_state & NUD_PERMANENT) - which is inconsistent with the add precondition, and inconsistent with its failure message text. As it is now, you can't delete any entry which add allows to be added - so entry deletion always fails.

Quoted 3 lines
Quoted 1 line

What about the ->ndm_state part of the add() test? Why not include that in the del() check?

I had three different thoughts about this:
1) Replicated the add check in the delete
2) Do what I did - make it where you can only delete those really
marked as static
3) Eliminate all delete checks

Quoted 5 lines

The problem is -- I'm not sure why the ndm->ndm_state check is in there -- I don't know how to make that condition occur. It has the feel of a check to be made before things are fully initialized - or maybe even just leftover cruft.

The test is there to support simultaneous master and self operations. The operation on a master may not always require a NUD_PERMANENT state (ex: bridge) and we don't want to perform self operations in that instance.

Quoted 2 lines

You could make the argument that option (3) is the best -- if it's been added successfully, you ought to be able to delete it.

Hmm.. _del() always deletes and flags/states don't matter much generally. I agree that the check isn't really needed as it isn't really protecting anything.

-vlad

Quoted 7 lines

If someone with more knowledge would comment that would be much appreciated!

I'm happy to submit any of these three versions of the patch. Let me know what's wanted.

#4 lore raw
Quoted 38 lines · Vlad Yasevich
Quoted 26 lines · Alan Robertson
Quoted 16 lines · David Miller

From: Alan Robertson <[email protected]>
Date: Thu, 30 May 2013 16:01:55 -0600

Quoted 13 lines

ndo_dflt_fdb_del is checking for a condition which is opposite that which ndo_dflt_fdb_add enforces. ndo_dflt_fdb_add declares an error if (ndm->ndm_state && !(ndm->ndm_state) & NUD_PERMANENT)) - that is, if the
entry is static. This is consistent with the failure error message.

On the other hand, ndo_dflt_del() declares an error
if (ndm_state & NUD_PERMANENT) - which is inconsistent with the add precondition, and inconsistent with its failure message text. As it is now, you can't delete any entry which add allows to be added -
so entry deletion always fails.

Quoted 3 lines
Quoted 1 line

What about the ->ndm_state part of the add() test? Why not include that in the del() check?

I had three different thoughts about this:
1) Replicated the add check in the delete
2) Do what I did - make it where you can only delete those really
marked as static
3) Eliminate all delete checks

Quoted 5 lines

The problem is -- I'm not sure why the ndm->ndm_state check is in there -- I don't know how to make that condition occur. It has the feel of a check to be made before things are fully initialized - or maybe even just leftover cruft.

The test is there to support simultaneous master and self operations. The operation on a master may not always require a NUD_PERMANENT state (ex: bridge) and we don't want to perform self operations in that instance.

Quoted 6 lines
Quoted 2 lines

You could make the argument that option (3) is the best -- if it's been added successfully, you ought to be able to delete it.

Hmm.. _del() always deletes and flags/states don't matter much generally. I agree that the check isn't really needed as it isn't really protecting anything.

So is that what folks want me to do?

Signature · 3 lines
    Alan Robertson <[email protected]> - @OSSAlanR

"Openness is the foundation and preservative of friendship...  Let me claim from you at all times your undisguised opinions." - William Wilberforce
maintainer
#5 lore raw
In reply to Vlad Yasevich

From: Vlad Yasevich <[email protected]>
Date: Fri, 31 May 2013 13:11:47 -0400

Quoted 34 lines · Alan Robertson
Quoted 26 lines · David Miller
Quoted 16 lines

From: Alan Robertson <[email protected]>
Date: Thu, 30 May 2013 16:01:55 -0600

Quoted 13 lines

ndo_dflt_fdb_del is checking for a condition which is opposite that which ndo_dflt_fdb_add enforces. ndo_dflt_fdb_add declares an error if (ndm->ndm_state && !(ndm->ndm_state) & NUD_PERMANENT)) - that is, if the
entry is static. This is consistent with the failure error message.

On the other hand, ndo_dflt_del() declares an error
if (ndm_state & NUD_PERMANENT) - which is inconsistent with the add precondition, and inconsistent with its failure message text. As it is now, you can't delete any entry which add allows to be added -
so entry deletion always fails.

Quoted 3 lines
Quoted 1 line

What about the ->ndm_state part of the add() test? Why not include that in the del() check?

I had three different thoughts about this:
1) Replicated the add check in the delete
2) Do what I did - make it where you can only delete those really
marked as static
3) Eliminate all delete checks

Quoted 6 lines

The problem is -- I'm not sure why the ndm->ndm_state check is in there
-- I don't know how to make that condition occur. It has the feel of a check to be made before things are fully initialized - or maybe even just leftover cruft.

Quoted 4 lines

The test is there to support simultaneous master and self operations. The operation on a master may not always require a NUD_PERMANENT state (ex: bridge) and we don't want to perform self operations in that instance.

I still don't understand the ndm_state check. Please use different words to explain it so that even an idiot like me can understand.

Once we define what the check should exactly be I propose:

1) Keeping the check only in add()

2) Removing the state checks completely in del()

3) Validating at netdevice registry time or elsewhere that these default fdb ops are always used together. That wraps up everything to ensure that only doing the check in add() is provably correct.

#6 lore raw

I'd like to fix this problem - but it seems good to answer David Miller's question before we decide which way to go. I certainly don't know the answer...

I can do (1) and (2), but I'm not sure how to do (3) properly.

Vlad: Can you help out here?

Quoted 3 lines · David Miller

From: Vlad Yasevich <[email protected]>
Date: Fri, 31 May 2013 13:11:47 -0400

<snip>

Quoted 20 lines
Quoted 4 lines

The test is there to support simultaneous master and self operations. The operation on a master may not always require a NUD_PERMANENT state (ex: bridge) and we don't want to perform self operations in that instance.

I still don't understand the ndm_state check. Please use different words to explain it so that even an idiot like me can understand.

Once we define what the check should exactly be I propose:

1) Keeping the check only in add()

2) Removing the state checks completely in del()

3) Validating at netdevice registry time or elsewhere that these default fdb ops are always used together. That wraps up everything to ensure that only doing the check in add() is provably correct.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
    Alan Robertson <[email protected]> - @OSSAlanR

"Openness is the foundation and preservative of friendship...  Let me claim from you at all times your undisguised opinions." - William Wilberforce