Skip to content

Conversation

@yrkurapati
Copy link
Contributor

@yrkurapati yrkurapati commented Nov 14, 2025

JIRA Ticket: https://do-internal.atlassian.net/browse/GATEWAYS-4422

  • Adds new DumpPortMappings method to retrieve port mappings for all interfaces from Open vSwitch bridges
  • Parses ovs-ofctl show output to extract ofport numbers and MAC addresses using line-by-line parsing
  • Returns a map of interface names to PortAttr structs containing ofport and MAC address for each interface
  • Includes DumpPortMapping function variant to fetch port information for a single interface by name
  • Validates ofport range (0-65535) and MAC address format, handling empty output and malformed lines gracefully
  • Includes comprehensive test coverage with multiple test cases covering all scenarios

@yrkurapati yrkurapati force-pushed the GATEWAYS-4422-implement-go-openvswitch-api-for-ofport-interface-mapping branch from 24eb418 to 7a2a409 Compare November 14, 2025 23:11
@yrkurapati yrkurapati marked this pull request as ready for review November 17, 2025 18:41
@yrkurapati yrkurapati requested a review from do-msingh November 18, 2025 01:56
do-msingh
do-msingh previously approved these changes Nov 18, 2025
@yrkurapati yrkurapati force-pushed the GATEWAYS-4422-implement-go-openvswitch-api-for-ofport-interface-mapping branch from 23a13d6 to 9668b0a Compare November 18, 2025 21:51
@yrkurapati
Copy link
Contributor Author

Squashed into a single commit.

@yrkurapati yrkurapati force-pushed the GATEWAYS-4422-implement-go-openvswitch-api-for-ofport-interface-mapping branch from 9668b0a to 823eec1 Compare November 18, 2025 21:54
@yrkurapati yrkurapati force-pushed the GATEWAYS-4422-implement-go-openvswitch-api-for-ofport-interface-mapping branch from 823eec1 to 55954bd Compare November 18, 2025 21:54
// 'ovs-ofctl show':
//
// 7(interface1): addr:fe:4f:76:09:88:2b
func (p *PortMapping) UnmarshalText(b []byte) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't a regex be much nicer for this?

Copy link
Contributor Author

@yrkurapati yrkurapati Nov 18, 2025

Choose a reason for hiding this comment

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

We did move from regexp
#141 (comment)

I did observe the existing code (table, flow, PortStats all use strings)

Copy link
Contributor

Choose a reason for hiding this comment

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

Github links to comments that have been resolved don't show what you are trying to link. Could you quote the thread you're referencing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you follow semantics similar to parseEach() and define your own parseEachPort() or something like that, instead of regexp?

showPrefix =[]byte("OFPT_FEATURES_REPLY")

@yrkurapati
Copy link
Contributor Author

@jcooperdo when you have time... ty!

@yrkurapati yrkurapati marked this pull request as draft November 21, 2025 18:57
@yrkurapati
Copy link
Contributor Author

Converted this PR to a draft. After discussing with the team, we've decided to use the existing ovs-ofctl dump-ports approach (same method used by hvflowd) instead of implementing a new API with ovs-ofctl show.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants