Synthesizing safe and efficient kernel extensions for packet processing