libnetwork: ipvlan, macvlan: cleanup getDummyName utility#47994
libnetwork: ipvlan, macvlan: cleanup getDummyName utility#47994thaJeztah merged 4 commits intomoby:masterfrom
Conversation
The function description mentions that the returned value will contain a truncated ID, but the function was only prepending the prefix, which meant that callers had to be aware that truncating is necessary. This patch moves truncating the ID into the utility to make its use less error-prone, and to make the code a bite more DRY. Signed-off-by: Sebastiaan van Stijn <[email protected]>
The stringid.TruncateID utility is used to provide a consistent length
for "short IDs" (containers, networks). While the dummy interfaces need
a short identifier, they use their own format and don't have to follow
the same length as is used for "short IDs" elsewhere.
In addition, stringid.TruncateID has an additional check for the given
ID to contain colons (":"), which won't be the case for network-IDs that
are passed to it, so this check is redundant.
This patch moves the truncating local to the getDummyName function, so
that it can define its own semantics, independent of changes elsewhere.
Signed-off-by: Sebastiaan van Stijn <[email protected]>
The function description mentions that the returned value will contain a truncated ID, but the function was only prepending the prefix, which meant that callers had to be aware that truncating is necessary. This patch moves truncating the ID into the utility to make its use less error-prone, and to make the code a bite more DRY. Signed-off-by: Sebastiaan van Stijn <[email protected]>
The stringid.TruncateID utility is used to provide a consistent length
for "short IDs" (containers, networks). While the dummy interfaces need
a short identifier, they use their own format and don't have to follow
the same length as is used for "short IDs" elsewhere.
In addition, stringid.TruncateID has an additional check for the given
ID to contain colons (":"), which won't be the case for network-IDs that
are passed to it, so this check is redundant.
This patch moves the truncating local to the getDummyName function, so
that it can define its own semantics, independent of changes elsewhere.
Signed-off-by: Sebastiaan van Stijn <[email protected]>
357fa61 to
f741ca8
Compare
| stringid.TruncateID(nw.config.ID), | ||
| nw.config.ID, |
There was a problem hiding this comment.
Rebased, and (as discussed on slack) removing the TruncateID here, as it was just to keep a shorter error.
|
Discussing on Slack for a follow-up PR, I'll add some comments about these While things will likely fail loud if someone would ever change those, it doesn't hurt to add that information in a comment; I'll do that in a follow-up. related: here's where the limit is defined in the kernel: https://github.com/torvalds/linux/blob/46d1907d1caaaaa422ae814c52065f243caa010a/include/uapi/linux/if.h#L33 |
libnetwork/drivers/ipvlan: move truncating ID to getDummyName
The function description mentions that the returned value will contain
a truncated ID, but the function was only prepending the prefix, which
meant that callers had to be aware that truncating is necessary.
This patch moves truncating the ID into the utility to make its use
less error-prone, and to make the code a bite more DRY.
libnetwork/drivers/ipvlan: getDummyName don't use stringid.TruncateID
The stringid.TruncateID utility is used to provide a consistent length
for "short IDs" (containers, networks). While the dummy interfaces need
a short identifier, they use their own format and don't have to follow
the same length as is used for "short IDs" elsewhere.
In addition, stringid.TruncateID has an additional check for the given
ID to contain colons (":"), which won't be the case for network-IDs that
are passed to it, so this check is redundant.
This patch moves the truncating local to the getDummyName function, so
that it can define its own semantics, independent of changes elsewhere.
libnetwork/drivers/macvlan: move truncating ID to getDummyName
The function description mentions that the returned value will contain
a truncated ID, but the function was only prepending the prefix, which
meant that callers had to be aware that truncating is necessary.
This patch moves truncating the ID into the utility to make its use
less error-prone, and to make the code a bite more DRY.
libnetwork/drivers/macvlan: getDummyName don't use stringid.TruncateID
The stringid.TruncateID utility is used to provide a consistent length
for "short IDs" (containers, networks). While the dummy interfaces need
a short identifier, they use their own format and don't have to follow
the same length as is used for "short IDs" elsewhere.
In addition, stringid.TruncateID has an additional check for the given
ID to contain colons (":"), which won't be the case for network-IDs that
are passed to it, so this check is redundant.
This patch moves the truncating local to the getDummyName function, so
that it can define its own semantics, independent of changes elsewhere.
- A picture of a cute animal (not mandatory but encouraged)