Orion: Automatic Repair for Network Programs

Lei Shi, Yuepeng Wang, Rajeev Alur, Boon Thau LooarXiv 2021

Abstract

Debugging imperative network programs is a challenging task for developers because understanding various network modules and complicated data structures is typically time-consuming. To address the challenge, this paper presents an automated technique for repairing network programs from unit tests. Specifically, given as input a faulty network program and a set of unit tests, our approach localizes the fault through symbolic reasoning, and synthesizes a patch such that the repaired program can pass all unit tests. It applies domain-specific abstraction to simplify network data structures and utilizes modular analysis to facilitate function summary reuse for symbolic analysis. We implement the proposed techniques in a tool called NetRep and evaluate it on 10 benchmarks adapted from real-world software-defined networking controllers. The evaluation results demonstrate the effectiveness and efficiency of NetRep for repairing network programs.

Introduction

Software-Defined Networking (SDN) has revolutionized network management by introducing programmability. However, writing SDN controllers in imperative languages like Java or C++ remains error-prone. Debugging these systems is notoriously difficult due to complex network modules, heavy bit-manipulation in data structures (e.g., MAC or IP addresses), and often non-deterministic bugs.

While general-purpose program repair tools exist, they often struggle with the scale and specific nature of network code. Conversely, existing network-specific repair tools are typically limited to declarative domain-specific languages (DSLs). NetRep addresses this gap by providing an automated repair solution for the complex, imperative code used in real-world SDN controllers.

Methodology

NetRep follows a "locate then synthesize" workflow, enhanced by three core techniques designed to handle the unique challenges of network programming.

The NetRep architecture overview.

1. Domain-Specific Abstraction

Network code often utilizes complex bit-level operations for performance. NetRep replaces these with high-level logical specifications. For instance, it treats a MAC address comparison as a simple equality check rather than a series of bitwise operations. This abstraction prevents "state explosion" during symbolic analysis, making the process significantly more efficient.

2. Modular Analysis

Instead of analyzing the entire program monolithically, NetRep operates function-by-function. It utilizes function summaries for callees, allowing the tool to reuse analysis results and scale effectively to larger programs without re-analyzing deep call stacks repeatedly.

3. Symbolic Fault Localization & Synthesis

The repair process involves two main stages:

  • Localization: The tool converts the program and failing tests into SMT (Satisfiability Modulo Theories) formulas. By using "boolean guards" to relax constraints on specific lines, NetRep identifies potential fault locations. If relaxing a line allows the SMT solver to find a solution that passes the tests, that line is flagged.
  • Synthesis: Once a fault is located, NetRep defines a context-free grammar based on the variables and functions in scope. It performs an enumerative search to find an expression that satisfies the test requirements. To speed up this process, NetRep infers local pre- and post-conditions at the fault site to validate candidate patches locally before running the full test suite.

Evaluation

The authors evaluated NetRep using 10 benchmarks adapted from the commit history of Floodlight, a popular open-source SDN controller. These benchmarks, ranging from 212 to 809 lines of Jimple code, represent real-world bugs identified via commit messages.

Key Results

  • Effectiveness: NetRep successfully repaired 8 out of 10 real-world benchmarks. In 5 of these cases, it generated the exact patch created by human developers.
  • Efficiency: The average repair time was approximately 12.4 minutes (744 seconds), making it suitable for a developer's active workflow.
  • Comparison: NetRep outperformed Jaid, a state-of-the-art general-purpose Java repair tool, in both accuracy and the ability to avoid "overfitting" (where a patch passes tests but fails to fix the underlying logic).
  • Ablation Study: Experiments confirmed that both modular analysis and domain-specific abstractions are essential; removing either caused a sharp drop in performance.

Discussion and Future Work

NetRep demonstrates that abstraction and modularity are "force multipliers" for symbolic execution in the network domain. By focusing on high-level logic rather than bit-level details, symbolic execution becomes viable for interactive repair tasks.

However, limitations remain. Currently, NetRep returns the first valid patch found, which may not always be the most readable or optimal solution. Future iterations could include an interactive loop for developer feedback. Additionally, the tool currently focuses on expression replacement rather than synthesizing entirely new control flow structures (like new if-else blocks). Future work will also address complex unbounded data structures like HashMaps and integrate invariant inference to better handle complex loops.

Summary updated

BibTeX
@misc{shi2021orion,
  author = {Lei Shi and Yuepeng Wang and Rajeev Alur and Boon Thau Loo},
  title = {{Orion: Automatic Repair for Network Programs}},
  year = {2021},
  eprint = {2110.06303},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2110.06303},
}
Figure