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

How to express a 16-bit port number when generating for OF1.1+? #501

Closed
rsharo opened this issue Jul 15, 2016 · 2 comments
Closed

How to express a 16-bit port number when generating for OF1.1+? #501

rsharo opened this issue Jul 15, 2016 · 2 comments

Comments

@rsharo
Copy link

rsharo commented Jul 15, 2016

Hi folks,

I'm trying to add some Nicira-specific actions: resubmit, resubmit_table, and exit.

Defining the input file is pretty simple. (Nice work, all!) Here's an example for resubmit_table:

#version any

struct of_action_nicira_resubmit_table : of_action_nicira {
    uint16_t type == 65535;
    uint16_t len;
    uint32_t experimenter == 0x2320;
    uint16_t subtype == 0xe;
    of_port_no_t in_port;
    uint8_t table_id;
    pad(3);
};

The problem is, OpenVSwitch uses a 16-bit port number in this action even for versions of the OpenFlow protocol above 1.0. Is there a way to force in_port to be marshalled as a two byte field instead of four bytes for OpenFlow versions 1.1+... just for these experimenter actions?

I know I could define the field as a uint16_t, but then it wouldn't be expressed as an OFPort in the builders and accessors. Trying to figure out if there is a "right" way to do it.

@rsharo rsharo changed the title How to force 16-bit port number when generating for OF1.1+? How to express a 16-bit port number when generating for OF1.1+? Jul 15, 2016
@andi-bigswitch
Copy link
Contributor

Since this is somewhat of a custom case; I would suggest making it an uint16_t in the OpenFlow input file / layer.

You can define a custom java type mapping for this in java_type.py; along the lines of (untested)

# [under of_port]
of_port_nicira = JType("OFPort") \
         .op(read="OFPort.read2Bytes(bb)", write="$name.write2Bytes(bb)", default="OFPort.ANY")

exceptions = {
    #....
    'of_action_nicira_resubmit_table': { 'port': of_port_nicira }
}

@rsharo
Copy link
Author

rsharo commented Jul 15, 2016

@andi-bigswitch Thanks much!

I'll use uint16_t for now. Was just looking at the code you referenced... I'd want to do it for all three language bindings if I did it. Seems a little overkill to do that just for two experimenter types. Will revisit if it becomes a recurring problem.

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

No branches or pull requests

2 participants