Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use big endian to restore IP #147

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

LiZhenCheng9527
Copy link
Collaborator

What type of PR is this?
/kind bug

Which issue(s) this PR fixes:
Fixes #146

Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
@kmesh-bot kmesh-bot added the kind/bug Something isn't working label Mar 6, 2024
@hzxuzhonghu
Copy link
Member

cc @kwb0523

@@ -54,5 +54,5 @@ func ConvertPortToBigEndian(little uint32) uint32 {

// ConvertIpByteToUint32 converts ip to little-endian uint32 format
func ConvertIpByteToUint32(ip []byte) uint32 {
return binary.LittleEndian.Uint32(ip)
return binary.BigEndian.Uint32(ip)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the function comments as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func ConvertIpToUint32(ip string) uint32 {

Should this function also be modified?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the caller, i think we get the IP slices from istiod.

pkg/nets/nets.go Outdated
@@ -54,5 +54,5 @@ func ConvertPortToBigEndian(little uint32) uint32 {

// ConvertIpByteToUint32 converts ip to little-endian uint32 format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ConvertIpByteToUint32 converts ip to little-endian uint32 format
// ConvertIpByteToUint32 converts big-endian ip slices to uint32 format

Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
@kwb0523
Copy link
Contributor

kwb0523 commented Mar 6, 2024

cc @kwb0523

fixed in #138

@hzxuzhonghu
Copy link
Member

@kwb0523 Not sure, let's make a pr as smaller as possible. Not to couple with that bigger refactor one

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kmesh-bot kmesh-bot merged commit e5db146 into kmesh-net:main Mar 6, 2024
2 of 3 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ip bytes converts to uint32 incorrect
4 participants