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

LuaJIT BPF compiler, examples, tests #652

Merged
merged 1 commit into from
Oct 6, 2016
Merged

Conversation

vavrusa
Copy link
Contributor

@vavrusa vavrusa commented Aug 10, 2016

This is an initial commit of LuaJIT bytecode to BPF compiler project, that enables writing both kernel and user-part of the code in Lua.

It's by far complete, but very usable for socket filters, uprobes, kprobes, and tracepoints.
Compatibility checklist is in src/lua/README.md. Most of the BPF map types are supported,
complex types and arrays are supported with some limitations, most of the BPF helpers are supported.

  • There are examples for all these in examples/lua mirroring similar examples written in C.
  • There are several elementary tests, but no tests checking compiler features. These would be awesome, but would require BPF VM or at least pass through verifier to see if generated programs are valid.

TODO

  • figure out installation paths
  • figure out include paths for running tests
  • add busted and luacheck as dependencies
  • figure out if ljsyscall from rocks should be used
  • make sure rockspec still works
  • fixup documentation, add bits to reference guide

@4ast
Copy link
Member

4ast commented Aug 10, 2016

to the build bot:
ok to test

Copyright (c) 2016, Marek Vavrusa <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
Copy link
Member

Choose a reason for hiding this comment

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

do you have a strong reason to choose bsd 2-clause license?
the rest of the bcc is covered by apache2 license.
the main reason we picked apache2 is patent rights.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not at all, happy to go with apache2. I'll remove the LICENSE file and update rockspec for the next iteration. Do you want a license header in each file or is it enough when it's covered by the LICENSE.txt ?

Copy link
Member

Choose a reason for hiding this comment

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

all exported header files and examples have to have it. Single line like in tools/*.py would be enough though. Ideally all files... Just to avoid any ambiguity.
Pls squash and force push to have single commit for clean history.
Thanks!

@vavrusa vavrusa force-pushed the master branch 2 times, most recently from 0a3b1f2 to a9be447 Compare August 12, 2016 04:07
@vavrusa
Copy link
Contributor Author

vavrusa commented Aug 12, 2016

The library now works with squishy, and examples work after installing 🙌

@vmg - the library depends on ljsyscall (which implements bcc.vendor.posix, should it be left up to user to install it or vendored? I'd leave that up to user/package maintainer to install it either through luarocks or as a package - but I don't know.

Next step is tests - right now it vendors luaunit. I'd like to bring in luacheck for static analysis, and luacov for code coverage. The luacov depends on unit test library support, so since there are not many tests I'd prefer to go with busted as a replacement for luaunit with support for code coverage. Other option is to not do static analysis and code coverage and rewrite my few tests to luaunit. Do you have any strong opinion on this?

@4ast
Copy link
Member

4ast commented Sep 30, 2016

what is the status of this PR ? should it be rebased and merged? Any blockers?

@vavrusa
Copy link
Contributor Author

vavrusa commented Sep 30, 2016

There is some duplication of the functionality (ljsyscall vs bcc.vendor.posix) and unit tests (busted vs luaunit), but that can be sorted out on the go. I've been on vacation for the past few weeks, and I'm coming back tomorrow, so I'll continue the work on it next week.

@vavrusa vavrusa changed the title wip: imported LuaJIT BPF compiler, examples, tests LuaJIT BPF compiler, examples, tests Oct 5, 2016
this is initial commit of LuaJIT bytecode to BPF
compiler project that enables writing both kernel
and user-part of the code as Lua
@vavrusa
Copy link
Contributor Author

vavrusa commented Oct 5, 2016

Rebased to latest master and updated the code. The imported tests now run with busted (if busted is found by CMake).

@4ast
Copy link
Member

4ast commented Oct 6, 2016

looks great. thanks a lot!

@4ast 4ast merged commit 676f357 into iovisor:master Oct 6, 2016
@vavrusa
Copy link
Contributor Author

vavrusa commented Oct 6, 2016

thanks! now the real work starts

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

2 participants