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

Flexible pipeline - #1 Architecture #3035

Conversation

hongliangl
Copy link
Contributor

Architecture code of flexible pipeline.

Signed-off-by: Hongliang Liu lhongliang@vmware.com

@hongliangl hongliangl changed the title Flexible pipeline - Architecture Flexible pipeline - #1 Architecture Nov 17, 2021
@hongliangl hongliangl force-pushed the flexible-pipeline-#1 branch 3 times, most recently from fc49ff5 to 05eee0b Compare November 29, 2021 03:24
Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
template = &pipelineTemplate{
stageTables: map[binding.StageID][]tableRequest{
binding.ClassifierStage: {
tableRequest{ClassifierTable, 0x7f},
Copy link
Contributor

Choose a reason for hiding this comment

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

anywhere we can learn why here is setting as 0x7f? or will there be any update for existing ovs-pipeline design doc? https://github.com/antrea-io/antrea/blob/main/docs/design/ovs-pipeline.md

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. How the table priorities are decided? Should we define constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The order of table within a stage is decided by this priority. We don't need to define constants because priorities should be the same within a stage, otherwise the order of tables cannot be decided by priority. @jianjuns @luolanzone

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand your explanation. How 0x7f, 0x6f, 0x7d in this file are decided? If I add a new table later, how I decide the priority value?

break
}
}
} else if protocol == ofProtocolARP {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here you can use switch to make the whole structure more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated in #3058

RewriteMACRegMark = binding.NewOneBitRegMark(0, 11, "RewriteMAC")
// reg0[12]: Mark to indicate the packet is denied(Drop/Reject).
CnpDenyRegMark = binding.NewOneBitRegMark(0, 12, "CNPDeny")
// reg0[13..14]: Field to indicate disposition of Antrea Policy. It could have more bits to support more disposition
// that Antrea policy support in the future.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/Antrea policy/Antrea Policy/

// reg4[16..19]: Field to store the union value of Endpoint state and the mark of whether Service type is NodePort.
NodePortUnionField = binding.NewRegField(4, 16, 19, "NodePortUnion")
// reg4[21]: Mark to indicate the packet is from local AntreaFlexibleIPAM Pod.
// NotAntreaFlexibleIPAMRegMark will be used with RewriteMACRegMark, thus the reg id must not be same due to the limitation of ofnet library.
AntreaFlexibleIPAMRegMark = binding.NewOneBitRegMark(4, 21, "AntreaFlexibleIPAM")
NotAntreaFlexibleIPAMRegMark = binding.NewOneBitZeroRegMark(4, 21, "AntreaFlexibleIPAM")
// reg4[22..23]: Field to store the state of a connection of Service NodePort/LoadBalancer from gateway which
// requires SNAT or not.
// - 0b01: connection requires SNAT and is not marked with a ct mark.
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure which one is correct but I suppose all ct mark string should be the same, either CT mark or ct mark in comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe CT mark.

Comment on lines +18 to +19
"antrea.io/antrea/pkg/agent/config"
"antrea.io/antrea/pkg/agent/openflow/cookie"
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to below antrea.io import section

globalConjMatchFlowCache map[string]*conjMatchFlowContext
conjMatchFlowLock sync.Mutex // Lock for access globalConjMatchFlowCache
// policyCache is a storage that supports listing policyRuleConjunction with different indexers.
// It's guaranteed that one policyRuleConjunction is processed by at most one goroutine at any given time.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/It's guaranteed/It guarantees/

enableProxy,
enableAntreaPolicy,
supportEncap bool) feature {
gatewayIPs := make(map[binding.Protocol]net.IP)
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't see this variable gatewayIPs being used in following codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it's updated in #3058


package openflow

type featureVMConnectivity struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's this for? a placeholder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A placeholder, removed in #3058

@@ -0,0 +1,113 @@
// Copyright 2019 Antrea Authors
Copy link
Contributor

Choose a reason for hiding this comment

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

s/2019/2021/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.


type pipelineTemplate struct {
// Declare the tables and the corresponding priorities in the expected stage.
// If it is expected to enforce a packet to enter other tables in the same stage after leaving the current table,
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is expected to enforce -> To force

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I do not understand this sentence. Do you mean "a packet will enter all tables in the same stage in order of table priority"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean "a packet will enter all tables in the same stage in order of table priority"?
Order of tables within a stage is decided by their priorities. The packet will pass through all tables within the stage by the order which is decided by the priorities.

Copy link
Contributor

Choose a reason for hiding this comment

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

What you think about replacing the sentence with my version: "A packet will enter all tables in the same stage in order of table priority"?

binding "antrea.io/antrea/pkg/ovs/openflow"
)

type featureID int
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add comments to explain the terms in this file? Or another way explain them in a separate doc. It is impossible to understand them just looking at code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in #3058


// A table with a higher priority is assigned with a lower tableID, which means a packet should enter the table
// before others with lower priorities in the same stage.
type tableRequest struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Taking this one as an example, we should explain what is a tableRequest, before talking about fields in the struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in #3058

c.ofTable = binding.NewOFTable(id, c.name, 0, 0)
}

// A table with a higher priority is assigned with a lower tableID, which means a packet should enter the table
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to rephrase this. There is no relation between "a higher priority is assigned with a lower tableID" and "a packet should enter the table before others with lower priorities in the same stage".

Maybe: A packet enters tables with higher priorities before tables with lower priorities. A table with a higher priority is assigned with a smaller tableID.

But what is tableID? Do you mean tableRequest.priority? Then we should just say: A smaller value indicates a higher priority.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in #3058

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The part of code has been simplified. Please review #3058. @jianjuns Thanks!

template = &pipelineTemplate{
stageTables: map[binding.StageID][]tableRequest{
binding.ClassifierStage: {
tableRequest{ClassifierTable, 0x7f},
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. How the table priorities are decided? Should we define constants?

@hongliangl hongliangl closed this Dec 6, 2021
@hongliangl hongliangl mentioned this pull request Dec 7, 2021
@hongliangl hongliangl deleted the flexible-pipeline-#1 branch February 8, 2022 00:08
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.

None yet

3 participants