Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <termios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <sys/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <net_user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <os.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "slip.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <um_malloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static int slip_user_init(void *data, void *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct slip_data *pri = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	pri->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static int set_up_tty(int fd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct termios tios;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	if (tcgetattr(fd, &tios) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		printk(UM_KERN_ERR "could not get initial terminal "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		       "attributes\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	tios.c_cflag = CS8 | CREAD | HUPCL | CLOCAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	tios.c_iflag = IGNBRK | IGNPAR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	tios.c_oflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	tios.c_lflag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	for (i = 0; i < NCCS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		tios.c_cc[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	tios.c_cc[VMIN] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	tios.c_cc[VTIME] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	cfsetospeed(&tios, B38400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	cfsetispeed(&tios, B38400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		printk(UM_KERN_ERR "failed to set terminal attributes\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) struct slip_pre_exec_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int stdin_fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	int stdout_fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int close_me;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static void slip_pre_exec(void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	struct slip_pre_exec_data *data = arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (data->stdin_fd >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		dup2(data->stdin_fd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	dup2(data->stdout_fd, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (data->close_me >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		close(data->close_me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static int slip_tramp(char **argv, int fd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct slip_pre_exec_data pe_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	char *output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int pid, fds[2], err, output_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	err = os_pipe(fds, 1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		printk(UM_KERN_ERR "slip_tramp : pipe failed, err = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		       -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	pe_data.stdin_fd = fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	pe_data.stdout_fd = fds[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	pe_data.close_me = fds[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	err = run_helper(slip_pre_exec, &pe_data, argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		goto out_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	pid = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	output_len = UM_KERN_PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	output = uml_kmalloc(output_len, UM_GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (output == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		printk(UM_KERN_ERR "slip_tramp : failed to allocate output "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		       "buffer\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		os_kill_process(pid, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		goto out_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	close(fds[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	read_output(fds[0], output, output_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	printk("%s", output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	err = helper_wait(pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	close(fds[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	kfree(output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) out_close:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	close(fds[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	close(fds[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static int slip_open(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	struct slip_data *pri = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	char version_buf[sizeof("nnnnn\0")];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			 NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	int sfd, mfd, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	err = get_pty();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		printk(UM_KERN_ERR "slip-open : Failed to open pty, err = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		       -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	mfd = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	err = open(ptsname(mfd), O_RDWR, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		printk(UM_KERN_ERR "Couldn't open tty for slip line, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		       "err = %d\n", -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		goto out_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	sfd = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	err = set_up_tty(sfd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		goto out_close2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	pri->slave = sfd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	pri->slip.pos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	pri->slip.esc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	if (pri->gate_addr != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		sprintf(version_buf, "%d", UML_NET_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		strcpy(gate_buf, pri->gate_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		err = slip_tramp(argv, sfd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			printk(UM_KERN_ERR "slip_tramp failed - err = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 			       -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 			goto out_close2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		err = os_get_ifname(pri->slave, pri->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 			printk(UM_KERN_ERR "get_ifname failed, err = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			       -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			goto out_close2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		iter_addresses(pri->dev, open_addr, pri->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		err = os_set_slip(sfd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			printk(UM_KERN_ERR "Failed to set slip discipline "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			       "encapsulation - err = %d\n", -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			goto out_close2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	return mfd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) out_close2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	close(sfd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) out_close:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	close(mfd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static void slip_close(int fd, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	struct slip_data *pri = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	char version_buf[sizeof("nnnnn\0")];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	char *argv[] = { "uml_net", version_buf, "slip", "down", pri->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			 NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	if (pri->gate_addr != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		iter_addresses(pri->dev, close_addr, pri->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	sprintf(version_buf, "%d", UML_NET_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	err = slip_tramp(argv, pri->slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	if (err != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		printk(UM_KERN_ERR "slip_tramp failed - errno = %d\n", -err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	close(pri->slave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	pri->slave = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) int slip_user_read(int fd, void *buf, int len, struct slip_data *pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	return slip_proto_read(fd, buf, len, &pri->slip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int slip_user_write(int fd, void *buf, int len, struct slip_data *pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	return slip_proto_write(fd, buf, len, &pri->slip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static void slip_add_addr(unsigned char *addr, unsigned char *netmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			  void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct slip_data *pri = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (pri->slave < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	open_addr(addr, netmask, pri->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static void slip_del_addr(unsigned char *addr, unsigned char *netmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	struct slip_data *pri = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	if (pri->slave < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	close_addr(addr, netmask, pri->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) const struct net_user_info slip_user_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	.init		= slip_user_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	.open		= slip_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	.close	 	= slip_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	.remove	 	= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	.add_address	= slip_add_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	.delete_address = slip_del_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	.mtu		= BUF_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	.max_packet	= BUF_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) };