@@ -4792,6 +4792,41 @@ static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = {
47924792#endif /* CONFIG_IPV6_SEG6_BPF */
47934793
47944794#ifdef CONFIG_XDP_LUA
4795+ BPF_CALL_2 (bpf_lua_dataref , struct xdp_buff * , ctx , int , offset ) {
4796+ if (offset + ctx -> data < ctx -> data_end ) {
4797+ int data_ref ;
4798+
4799+ data_ref = ldata_newref (ctx -> L , ctx -> data + offset ,
4800+ ctx -> data_end - ctx -> data - offset );
4801+ return data_ref ;
4802+ }
4803+
4804+ return -1 ;
4805+ }
4806+
4807+ static const struct bpf_func_proto bpf_lua_dataref_proto = {
4808+ .func = bpf_lua_dataref ,
4809+ .gpl_only = false,
4810+ .pkt_access = false,
4811+ .ret_type = RET_INTEGER ,
4812+ .arg1_type = ARG_PTR_TO_CTX ,
4813+ .arg1_type = ARG_ANYTHING ,
4814+ };
4815+
4816+ BPF_CALL_2 (bpf_lua_dataunref , struct xdp_buff * , ctx , int , data_ref ) {
4817+ ldata_unref (ctx -> L , data_ref );
4818+ return 0 ;
4819+ }
4820+
4821+ static const struct bpf_func_proto bpf_lua_dataunref_proto = {
4822+ .func = bpf_lua_dataunref ,
4823+ .gpl_only = false,
4824+ .pkt_access = false,
4825+ .ret_type = RET_VOID ,
4826+ .arg1_type = ARG_PTR_TO_CTX ,
4827+ .arg2_type = ARG_ANYTHING ,
4828+ };
4829+
47954830BPF_CALL_4 (bpf_lua_pcall , struct xdp_buff * , ctx , char * , funcname ,
47964831 int , num_args , int , num_rets ) {
47974832 if (lua_getglobal (ctx -> L , funcname ) != LUA_TFUNCTION ) {
@@ -5022,6 +5057,10 @@ bpf_base_func_proto(enum bpf_func_id func_id)
50225057 return bpf_get_trace_printk_proto ();
50235058 /* else: fall through */
50245059#ifdef CONFIG_XDP_LUA
5060+ case BPF_FUNC_lua_dataref :
5061+ return & bpf_lua_dataref_proto ;
5062+ case BPF_FUNC_lua_dataunref :
5063+ return & bpf_lua_dataunref_proto ;
50255064 case BPF_FUNC_lua_pcall :
50265065 return & bpf_lua_pcall_proto ;
50275066 case BPF_FUNC_lua_pop :
0 commit comments