@@ -4797,6 +4797,41 @@ static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = {
47974797#endif /* CONFIG_IPV6_SEG6_BPF */
47984798
47994799#ifdef CONFIG_XDP_LUA
4800+ BPF_CALL_2 (bpf_lua_dataref , struct xdp_buff * , ctx , int , offset ) {
4801+ if (offset + ctx -> data < ctx -> data_end ) {
4802+ int data_ref ;
4803+
4804+ data_ref = ldata_newref (ctx -> L , ctx -> data + offset ,
4805+ ctx -> data_end - ctx -> data - offset );
4806+ return data_ref ;
4807+ }
4808+
4809+ return -1 ;
4810+ }
4811+
4812+ static const struct bpf_func_proto bpf_lua_dataref_proto = {
4813+ .func = bpf_lua_dataref ,
4814+ .gpl_only = false,
4815+ .pkt_access = false,
4816+ .ret_type = RET_INTEGER ,
4817+ .arg1_type = ARG_PTR_TO_CTX ,
4818+ .arg1_type = ARG_ANYTHING ,
4819+ };
4820+
4821+ BPF_CALL_2 (bpf_lua_dataunref , struct xdp_buff * , ctx , int , data_ref ) {
4822+ ldata_unref (ctx -> L , data_ref );
4823+ return 0 ;
4824+ }
4825+
4826+ static const struct bpf_func_proto bpf_lua_dataunref_proto = {
4827+ .func = bpf_lua_dataunref ,
4828+ .gpl_only = false,
4829+ .pkt_access = false,
4830+ .ret_type = RET_VOID ,
4831+ .arg1_type = ARG_PTR_TO_CTX ,
4832+ .arg2_type = ARG_ANYTHING ,
4833+ };
4834+
48004835BPF_CALL_4 (bpf_lua_pcall , struct xdp_buff * , ctx , char * , funcname ,
48014836 int , num_args , int , num_rets ) {
48024837 if (lua_getglobal (ctx -> L , funcname ) != LUA_TFUNCTION ) {
@@ -5027,6 +5062,10 @@ bpf_base_func_proto(enum bpf_func_id func_id)
50275062 return bpf_get_trace_printk_proto ();
50285063 /* else: fall through */
50295064#ifdef CONFIG_XDP_LUA
5065+ case BPF_FUNC_lua_dataref :
5066+ return & bpf_lua_dataref_proto ;
5067+ case BPF_FUNC_lua_dataunref :
5068+ return & bpf_lua_dataunref_proto ;
50305069 case BPF_FUNC_lua_pcall :
50315070 return & bpf_lua_pcall_proto ;
50325071 case BPF_FUNC_lua_pop :
0 commit comments