Skip to content

Commit

Permalink
Refactor ubpfDeparser to properly emit outgoing packet size calculati…
Browse files Browse the repository at this point in the history
…on (#2237)
  • Loading branch information
osinstom authored Mar 12, 2020
1 parent f551582 commit 6ea9e17
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backends/ubpf/ubpfDeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace UBPF {
{ return illegal(statement); }
bool preorder(const IR::BlockStatement* statement) override {}
bool preorder(const IR::MethodCallStatement* statement) override {
LOG5("Calculate OutHeaderSize");
auto &p4lib = P4::P4CoreLibrary::instance;

auto mi = P4::MethodInstance::resolve(statement->methodCall, refMap, typeMap);
Expand Down Expand Up @@ -322,13 +323,13 @@ namespace UBPF {
builder->appendFormat("int %s = 0", program->outerHdrLengthVar.c_str());
builder->endOfStatement(true);

OutHeaderSize ohs(program->refMap, program->typeMap,
static_cast<const UBPFProgram*>(program));
ohs.substitute(headers, parserHeaders);
ohs.setBuilder(builder);
auto ohs = new OutHeaderSize(program->refMap, program->typeMap,
static_cast<const UBPFProgram*>(program));
ohs->substitute(headers, parserHeaders);
ohs->setBuilder(builder);

builder->emitIndent();
(void)controlBlock->container->body->apply(ohs);
controlBlock->container->body->apply(*ohs);
builder->newline();

builder->emitIndent();
Expand Down

0 comments on commit 6ea9e17

Please sign in to comment.