Skip to content

Commit

Permalink
Limit interface name (#1022)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <[email protected]>
  • Loading branch information
glazychev-art authored Jul 15, 2021
1 parent f36729d commit 7f3f374
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/networkservice/common/mechanisms/kernel/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k *kernelMechanismClient) Request(ctx context.Context, request *networkser
},
}
if k.interfaceName != "" {
mechanism.Parameters[kernel.InterfaceNameKey] = k.interfaceName
mechanism.Parameters[kernel.InterfaceNameKey] = limitName(k.interfaceName)
}
request.MechanismPreferences = append(request.GetMechanismPreferences(), mechanism)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/networkservice/common/mechanisms/kernel/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ func GetNameFromConnection(conn *networkservice.Connection) string {
ns = ns[:nsMaxLength]
}
name := fmt.Sprintf("%s-%s", ns, conn.GetId())
return limitName(name)
}

func limitName(name string) string {
if len(name) > kernelmech.LinuxIfMaxLength {
name = name[:kernelmech.LinuxIfMaxLength]
return name[:kernelmech.LinuxIfMaxLength]
}
return name
}

0 comments on commit 7f3f374

Please sign in to comment.