1.ubus path change 2.fix oaf compile error v5.5+

This commit is contained in:
derry 2021-06-28 12:45:45 +00:00
parent 504b33ac21
commit 2474c46bbc
3 changed files with 27 additions and 6 deletions

View File

@ -149,6 +149,8 @@ static int af_client_open(struct inode *inode, struct file *file)
return 0;
}
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,5,0)
static const struct file_operations af_client_fops = {
.owner = THIS_MODULE,
.open = af_client_open,
@ -156,7 +158,15 @@ static const struct file_operations af_client_fops = {
.llseek = seq_lseek,
.release = seq_release_private,
};
#else
static const struct proc_ops af_client_fops = {
.proc_flags = PROC_ENTRY_PERMANENT,
.proc_read = seq_read,
.proc_open = af_client_open,
.proc_lseek = seq_lseek,
.proc_release = seq_release_private,
};
#endif
#define AF_CLIENT_PROC_STR "af_client"
@ -165,7 +175,10 @@ int init_af_client_procfs(void)
{
struct proc_dir_entry *pde;
struct net *net = &init_net;
pde = proc_create(AF_CLIENT_PROC_STR, 0440, net->proc_net, &af_client_fops);
// pde = proc_create(AF_CLIENT_PROC_STR, 0440, net->proc_net, &af_client_fops);
pde = proc_create(AF_CLIENT_PROC_STR, 0440, net->proc_net, &af_client_fops);
if (!pde) {
AF_ERROR("nf_client proc file created error\n");
return -1;

View File

@ -299,15 +299,19 @@ void load_feature_buf_from_file(char **config_buf)
filp_close(fp, NULL);
return;
}
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,7,19)
fs = get_fs();
set_fs(KERNEL_DS);
#endif
// 4.14rc3 vfs_read-->kernel_read
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
kernel_read(fp, *config_buf, size, &(fp->f_pos));
#else
vfs_read(fp, *config_buf, size, &(fp->f_pos));
#endif
set_fs(fs);
/// set_fs(fs);
filp_close(fp, NULL);
}

View File

@ -512,9 +512,13 @@ static void appfilter_add_object(struct ubus_object *obj)
int appfilter_ubus_init(void)
{
ubus_ctx = ubus_connect("/var/run/ubus.sock");
if (!ubus_ctx)
return -EIO;
ubus_ctx = ubus_connect("/var/run/ubus/ubus.sock");
if (!ubus_ctx){
ubus_ctx = ubus_connect("/var/run/ubus.sock");
}
if (!ubus_ctx){
return -EIO;
}
appfilter_add_object(&main_object);
ubus_add_uloop(ubus_ctx);