GNU General Public License v3.0

项目介绍

lac-dcc/honey-potion 是一个托管在 GitHub 上的开源项目,主要使用 C 编写,采用 GNU General Public License v3.0 许可证,目前获得 296 个 Star、11 次 Fork。

仓库全名
lac-dcc/honey-potion
开源许可证
GNU General Public License v3.0
Star 数
296
Fork 数
11
未关闭 Issue
10

README 摘要

🍯 Honey Potion - Writing eBPF with Elixir 🍯 🐝 About Honey Potion is a framework that brings the power of eBPF to Elixir, allowing users to write Elixir code that is transformed into eBPF bytecode. In this alpha version, Honey Potion translates Elixir code into a subset of C that leverages libbpf. The generated C code is then compiled using clang to produce the eBPF bytecode, which can be loaded into the kernel…

完整内容见 GitHub 原始 README 或本页 。

常见问题

honey-potion 用什么语言开发?

主要使用 C 编写,采用 GNU General Public License v3.0 许可证,目前有 296 个 Star。

honey-potion 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 honey-potion 的源码?

可以直接克隆仓库:git clone https://github.com/lac-dcc/honey-potion.git,默认分支为 main;安装与运行步骤见仓库 README。

honey-potion 最近还在维护吗?

仓库最近一次更新为 9月7日,当前有 10 个未关闭 Issue;Star 数为 296,可作为社区活跃度的参考。

关于

Writing eBPF programs with Elixir!

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
325
价值分
181
活跃状态
活跃

语言占比

C
Dockerfile
Elixir
LLVM
Makefile
Nix
Shell

Release

README

🍯 Honey Potion - Writing eBPF with Elixir 🍯

Hex Version Hex Docs Total Download License Last Updated join discord

🐝 About

Honey Potion is a framework that brings the power of eBPF to Elixir, allowing users to write Elixir code that is transformed into eBPF bytecode.

In this alpha version, Honey Potion translates Elixir code into a subset of C that leverages libbpf. The generated C code is then compiled using clang to produce the eBPF bytecode, which can be loaded into the kernel.

Honey Potion Logo


📦 Dependencies

Honey Potion requires the following dependencies, listed with their Ubuntu package names (equivalents exist for other distributions):

  • Erlang & Elixir – Required for running Honey Potion
  • libbpf – Version 1.1 (installation guide)
  • gcc-multilib – Required for certain C libraries (asm/types.h)
  • make – For Makefile-based compilation
  • llvm – Provides llc
  • clang – Required for compilation
  • bpftool – Used for skeleton generation

ℹ️ Note: You can manually compile clang, llc, and bpftool, as long as they are available in your $PATH.


🎥 Video Guide

Prefer a video tutorial? Check out the Honey Potion YouTube playlist with step-by-step guides.

YouTube Thumbnail


🚀 Installation

Add honey to your project’s dependencies in mix.exs:

def deps do
  [
    {:honey, git: "https://github.com/lac-dcc/honey-potion/", submodules: true}
  ]
end

📝 Usage

When you use Honey in your module, it will be translated to C the next time you compile your project.

defmodule Minimal do
  use Honey, license: "Dual BSD/GPL"
  # ...
end

This generates the following directories:

  • src/ – Stores the generated C code (e.g., Minimal.bpf.c)
  • obj/ – Stores compilation objects (e.g., Minimal.o)
  • bin/ – Stores the final executable (e.g., Minimal)

To run your program, navigate to the bin/ directory and execute the binary with appropriate privileges.

🔧 Command-line Options

  • -p → Prints all eBPF maps
  • -t <seconds> → Specifies the duration the program should run
🎯 The main/1 Function

Every module using Honey must define a main/1 function that serves as the entry point for the eBPF program.

defmodule Example.Minimal do
  use Honey, license: "Dual BSD/GPL"

  @sec "tracepoint/syscalls/sys_enter_kill"
  def main(ctx) do
    # ...
  end
end
  • @sec specifies the program type according to libbpf.
  • ctx is a struct whose fields vary depending on the program type.
  • The main/1 function must return an integer; otherwise, a runtime exception is thrown.

For detailed documentation and examples, see:

Or watch the YouTube tutorial.


⚠️ Runtime Exceptions

As Elixir is a dynamically typed language, we simulate runtime exceptions when translating programs to eBPF.

In this Alpha version, if an exception occurs, it will be printed to the debug pipe, and the program will exit with status 0.


🚧 Current Limitations

Honey Potion is still in Alpha, and many features are still being developed. Some known limitations include:

  • Pattern Matching: No destructuring; = behaves like an assignment operator.
  • Control Flow: No case or if-else blocks (unless optimized out at compile time).
  • Operators: Limited to +, -, *, /, and ==.
  • Function Guards: Not supported.
  • Default Arguments: Not supported.
  • Recursion: No mutual recursion support.
  • Structs: User-defined structs are not supported.
  • Execution Requirements: Executable must reside in bin/, and the object file must be in obj/.

We are actively working to improve Honey Potion. Stay tuned!


🤝 Contributing

Contributions are welcome! To avoid redundant work, please reach out before submitting major changes.

Feedback and suggestions are highly appreciated! You can:


📜 License

Honey Potion is maintained by the Compilers Laboratory at the Federal University of Minas Gerais (UFMG), Brazil.

This program is free software under the terms of the GNU General Public License (GPLv3).

For details, see the full license: GNU GPL v3.


评论

暂无评论