newip静态告警清理

Signed-off-by: yangyanjun <yangyanjun@huawei.com>
This commit is contained in:
yangyanjun
2022-11-25 09:45:23 +08:00
parent fe61b5a9df
commit 9efd28f28a
21 changed files with 105 additions and 85 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
{
int af_ninet = check_nip_enable();
if (g_nip_enable)
if (af_ninet)
printf("Support NewIP.\n\n");
else
printf("Not support NewIP.\n\n");
+19 -6
View File
@@ -45,7 +45,7 @@
* ioctl(fd, SIOGIFINDEX, &ifr);
* ifr.ifr_ifindex; ===> ifindex
*/
int32_t nip_add_addr(int32_t ifindex, struct nip_addr *addr, int opt)
int32_t nip_add_addr(int32_t ifindex, const struct nip_addr *addr, int opt)
{
int fd, ret;
struct nip_ifreq ifrn;
@@ -60,7 +60,7 @@ int32_t nip_add_addr(int32_t ifindex, struct nip_addr *addr, int opt)
ret = ioctl(fd, opt, &ifrn);
if (ret < 0 && errno != EEXIST) { // ignore File Exists error
printf("cfg newip addr fail, ifindex=%d, opt=%u, ret=%d.\n", ifindex, opt, ret);
printf("cfg newip addr fail, ifindex=%d, opt=%d, ret=%d.\n", ifindex, opt, ret);
close(fd);
return -1;
}
@@ -80,6 +80,7 @@ int main(int argc, char **argv_input)
{
int ret;
int opt;
unsigned int len;
int ifindex = 0;
char **argv = argv_input;
char cmd[ARRAY_LEN];
@@ -87,7 +88,7 @@ int main(int argc, char **argv_input)
struct nip_addr addr = {0};
if (argc != DEMO_INPUT_3) {
printf("unsupport addr cfg input, argc=%u.\n", argc);
printf("unsupport addr cfg input, argc=%d.\n", argc);
cmd_help();
return -1;
}
@@ -95,7 +96,13 @@ int main(int argc, char **argv_input)
/* 配置参数1解析: <netcard-name> */
argv++;
memset(dev, 0, ARRAY_LEN);
ret = sscanf(*argv, "%s", dev);
len = strlen(*argv);
if (!len || len >= (ARRAY_LEN - 1))
return -1;
memcpy(dev, *argv, len);
dev[len + 1] = '\0';
if (strncmp(dev, "wlan", NAME_WLAN_LEN)) {
printf("unsupport addr cfg cmd-1, cmd=%s.\n", dev);
cmd_help();
@@ -108,7 +115,13 @@ int main(int argc, char **argv_input)
/* 配置参数2解析: { add | del } */
argv++;
memset(cmd, 0, ARRAY_LEN);
ret = sscanf(*argv, "%s", cmd);
len = strlen(*argv);
if (!len || len >= (ARRAY_LEN - 1))
return -1;
memcpy(cmd, *argv, len);
cmd[len + 1] = '\0';
if (!strncmp(cmd, "add", NAME_WLAN_LEN)) {
opt = SIOCSIFADDR;
} else if (!strncmp(cmd, "del", NAME_WLAN_LEN)) {
@@ -131,7 +144,7 @@ int main(int argc, char **argv_input)
if (ret != 0)
return -1;
printf("%s (ifindex=%u) cfg addr success.\n", dev, ifindex);
printf("%s (ifindex=%d) cfg addr success.\n", dev, ifindex);
return 0;
}
+1 -1
View File
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
if (ret != 0)
return -1;
printf("%s %s(ifindex=%u) cfg addr success.\n", *argv, NIC_NAME, ifindex);
printf("%s %s(ifindex=%d) cfg addr success.\n", *argv, NIC_NAME, ifindex);
return 0;
}
+11 -5
View File
@@ -87,14 +87,14 @@ int nip_addr_fmt(char *addr_str, struct nip_addr *sap, int addrlen_input)
} else if (addr_str[i] >= 'a' && addr_str[i] <= 'f') {
addr_str[i] = addr_str[i] - STR_FMT_2;
} else {
printf("Newip addr error: uaddr[%u]=%c.\n", i, addr_str[i]);
printf("Newip addr error: uaddr[%d]=%c.\n", i, addr_str[i]);
return 1;
}
}
first_byte = addr_str[0] << NIP_ADDR_LEN_4;
first_byte += addr_str[1];
if (first_byte >= 0x00 && first_byte <= ADDR_FIRST_DC)
if (first_byte <= ADDR_FIRST_DC)
addrlen = NIP_ADDR_LEN_1;
else if ((first_byte > ADDR_FIRST_DC && first_byte <= ADDR_FIRST_F0) ||
(first_byte == ADDR_FIRST_FF))
@@ -117,7 +117,7 @@ int nip_addr_fmt(char *addr_str, struct nip_addr *sap, int addrlen_input)
sap->bitlen = addrlen * NIP_ADDR_LEN_8;
printf("*************************************************\n");
printf("Newip addr len=%u\n", addrlen);
printf("Newip addr len=%d\n", addrlen);
for (i = 0; i < addrlen; i++) {
sap->nip_addr_field8[i] = addr_str[i * INDEX_2] << INDEX_4;
sap->nip_addr_field8[i] += addr_str[i * INDEX_2 + 1];
@@ -131,6 +131,7 @@ int nip_addr_fmt(char *addr_str, struct nip_addr *sap, int addrlen_input)
int nip_get_addr(char **args, struct nip_addr *addr)
{
int ret;
unsigned int len;
char *sp = *args;
int addrlen_input = 0;
__u8 addr_str[INDEX_MAX] = {0};
@@ -141,11 +142,16 @@ int nip_get_addr(char **args, struct nip_addr *addr)
}
if (addrlen_input % ADDR_STR_LEN != 0) {
printf("NewIP addr str-len invalid, addrlen_input=%u.\n", addrlen_input);
printf("NewIP addr str-len invalid, addrlen_input=%d.\n", addrlen_input);
return -1;
}
ret = sscanf(*args, "%s", addr_str);
len = strlen(*args);
if (!len || len >= (INDEX_MAX - 1))
return -1;
memcpy(addr_str, *args, len);
addr_str[len + 1] = '\0';
return nip_addr_fmt(addr_str, addr, addrlen_input / ADDR_STR_LEN);
}
+19 -8
View File
@@ -47,8 +47,8 @@
* ioctl(fd, SIOGIFINDEX, &ifr);
* ifr.ifr_ifindex; ===> ifindex
*/
int nip_route_add(int ifindex, struct nip_addr *dst_addr, struct nip_addr *gateway_addr,
uint8_t gateway_flag, int opt)
int nip_route_add(int ifindex, const struct nip_addr *dst_addr,
const struct nip_addr *gateway_addr, uint8_t gateway_flag, int opt)
{
int fd, ret;
struct nip_rtmsg rt;
@@ -92,9 +92,8 @@ int main(int argc, char **argv_input)
{
int ret;
int opt;
unsigned int len;
int ifindex = 0;
uint8_t dst_addr_len;
uint8_t gateway_addr_len;
uint8_t gateway_flag = 0;
char **argv = argv_input;
char cmd[ARRAY_LEN];
@@ -103,7 +102,7 @@ int main(int argc, char **argv_input)
struct nip_addr gateway_addr = {0};
if (argc != DEMO_INPUT_3 && argc != DEMO_INPUT_4) {
printf("unsupport route cfg input, argc=%u.\n", argc);
printf("unsupport route cfg input, argc=%d.\n", argc);
cmd_help();
return -1;
}
@@ -111,7 +110,13 @@ int main(int argc, char **argv_input)
/* 配置参数1解析: { add | del } */
argv++;
memset(cmd, 0, ARRAY_LEN);
ret = sscanf(*argv, "%s", cmd);
len = strlen(*argv);
if (!len || len >= (ARRAY_LEN - 1))
return -1;
memcpy(cmd, *argv, len);
cmd[len + 1] = '\0';
if (!strncmp(cmd, "add", NAME_WLAN_LEN)) {
opt = SIOCADDRT;
} else if (!strncmp(cmd, "del", NAME_WLAN_LEN)) {
@@ -133,7 +138,13 @@ int main(int argc, char **argv_input)
/* 配置参数3解析: <netcard-name> */
argv++;
memset(dev, 0, ARRAY_LEN);
ret = sscanf(*argv, "%s", dev);
len = strlen(*argv);
if (!len || len >= (ARRAY_LEN - 1))
return -1;
memcpy(dev, *argv, len);
dev[len + 1] = '\0';
if (strncmp(dev, "wlan", NAME_WLAN_LEN)) {
printf("unsupport route cfg cmd-3, cmd=%s.\n", dev);
cmd_help();
@@ -166,7 +177,7 @@ int main(int argc, char **argv_input)
return -1;
}
printf("%s (ifindex=%u) cfg route success.\n", dev, ifindex);
printf("%s (ifindex=%d) cfg route success.\n", dev, ifindex);
return 0;
}
+1 -3
View File
@@ -87,8 +87,6 @@ int main(int argc, char **argv)
uint8_t server_addr[INDEX_2] = {0xDE, 0x00}; // 2-byte address of the server: 0xDE00
uint8_t *dst_addr;
uint8_t dst_addr_len;
uint8_t *gateway_addr;
uint8_t gateway_addr_len;
if (argc == DEMO_INPUT_1) {
if (!strcmp(*(argv + 1), "server")) {
@@ -121,7 +119,7 @@ int main(int argc, char **argv)
return -1;
}
printf("%s %s(ifindex=%u) cfg route success.\n", *argv, NIC_NAME, ifindex);
printf("%s %s(ifindex=%d) cfg route success.\n", *argv, NIC_NAME, ifindex);
return 0;
}
+5 -2
View File
@@ -57,7 +57,6 @@ void *send_recv(void *args)
fd_set readfds;
struct timeval tv, stTime;
struct thread_args *th_args = (struct thread_args *) args;
struct sockaddr_nin si_server = th_args->si_server;
cfd = th_args->cfd;
for (int i = 0; i < PKTCNT; i++) {
@@ -86,6 +85,10 @@ void *send_recv(void *args)
(void)gettimeofday(&stTime, NULL);
ret = sscanf(buf, "%d %d NIP_TCP # %d",
&sendtime_sec, &sendtime_usec, &no);
if (ret <= 0) {
perror("sscanf");
goto END;
}
printf("Received --%s sock %d success:%6d/%6d/no=%6d\n",
buf, cfd, success, count + 1, no);
} else {
@@ -125,7 +128,7 @@ int main(int argc, char **argv)
perror("connect");
return -1;
}
printf("connect success, addr=0x%02x%02x, port=%u\n",
printf("connect success, addr=0x%02x%02x, port=%d\n",
si_server.sin_addr.nip_addr_field8[INDEX_0],
si_server.sin_addr.nip_addr_field8[INDEX_1], TCP_SERVER_PORT);
+1 -1
View File
@@ -95,7 +95,7 @@ int main(int argc, char **argv)
perror("bind");
goto END;
}
printf("bind success, addr=0x%02x%02x, port=%u\n",
printf("bind success, addr=0x%02x%02x, port=%d\n",
si_local.sin_addr.nip_addr_field8[INDEX_0],
si_local.sin_addr.nip_addr_field8[INDEX_1], TCP_SERVER_PORT);
+2 -2
View File
@@ -50,7 +50,7 @@ void *recv_send(void *args)
int fd, ret, recv_num;
int count = 0;
socklen_t slen;
struct sockaddr_nin si_local, si_remote;
struct sockaddr_nin si_remote;
memcpy(&fd, args, sizeof(int));
while (count < PKTCNT) {
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
goto END;
}
printf("bind success, addr=0x%02x%02x, port=%u\n",
printf("bind success, addr=0x%02x%02x, port=%d\n",
si_local.sin_addr.nip_addr_field8[INDEX_0],
si_local.sin_addr.nip_addr_field8[INDEX_1], UDP_SERVER_PORT);
+1 -1
View File
@@ -33,7 +33,7 @@
#define USHORT_PAYLOAD 16
#define NIP_CHECKSUM_UINT8_PAYLOAD 8
unsigned int _nip_check_sum(unsigned char *data, unsigned short data_len)
unsigned int _nip_check_sum(const unsigned char *data, unsigned short data_len)
{
unsigned int i = 0, sum = 0;
+1 -1
View File
@@ -225,7 +225,7 @@ void nip_hdr_comm_encap(struct nip_hdr_encap *head);
void nip_update_total_len(struct nip_hdr_encap *head, unsigned short total_len);
/* Note: a function call requires its own byte order conversion.(niph->total_len) */
int nip_hdr_parse(unsigned char *buf, unsigned int buf_len, struct nip_hdr_decap *niph);
int nip_hdr_parse(unsigned char *rcv_buf, unsigned int buf_len, struct nip_hdr_decap *niph);
/* The length of the packet header is obtained according to the packet type,
* source ADDRESS, and destination address.
+5 -5
View File
@@ -53,7 +53,7 @@ static int _get_nip_hdr_bitmap(unsigned char *buf,
}
/* Must carry the current field */
static int _get_nip_hdr_ttl(unsigned char *buf,
static int _get_nip_hdr_ttl(const unsigned char *buf,
unsigned char bitmap,
struct nip_hdr_decap *niph)
{
@@ -70,7 +70,7 @@ static int _get_nip_hdr_ttl(unsigned char *buf,
/* Communication between devices of the same version may not carry packet Header length,
* but communication between devices of different versions must carry packet header length
*/
static int _get_nip_hdr_len(unsigned char *buf,
static int _get_nip_hdr_len(const unsigned char *buf,
unsigned char bitmap,
struct nip_hdr_decap *niph)
{
@@ -90,7 +90,7 @@ static int _get_nip_hdr_len(unsigned char *buf,
}
/* Must carry the current field */
static int _get_nip_hdr_nexthdr(unsigned char *buf,
static int _get_nip_hdr_nexthdr(const unsigned char *buf,
unsigned char bitmap,
struct nip_hdr_decap *niph)
{
@@ -260,7 +260,6 @@ static int nip_hdr_check(struct nip_hdr_decap *niph)
int nip_hdr_parse(unsigned char *rcv_buf, unsigned int buf_len, struct nip_hdr_decap *niph)
{
int i = 0;
int len;
int ret;
unsigned char *buf = rcv_buf;
unsigned char bitmap[BITMAP_MAX] = {0};
@@ -276,7 +275,8 @@ int nip_hdr_parse(unsigned char *rcv_buf, unsigned int buf_len, struct nip_hdr_d
while (i < num) {
if (i >= FACTORY_NUM_MAX)
break;
len = hdr_parse_factory[i](buf, bitmap[i], niph);
int len = hdr_parse_factory[i](buf, bitmap[i], niph);
if (len < 0)
return len;
-2
View File
@@ -119,8 +119,6 @@ static int ninet_create(struct net *net, struct socket *sock, int protocol,
if (err)
goto out_rcu_unlock;
err = -EPERM;
sock->ops = answer->ops;
answer_prot = answer->prot;
answer_flags = answer->flags;
+3 -1
View File
@@ -347,10 +347,12 @@ static struct sock *ninet_lhash2_lookup(struct net *net,
{
struct inet_connection_sock *icsk;
struct sock *sk, *result = NULL;
int score, hiscore = 0, matches = 0, reuseport = 0;
int hiscore = 0, matches = 0, reuseport = 0;
u32 phash = 0;
inet_lhash2_for_each_icsk_rcu(icsk, &ilb2->head) {
int score;
sk = (struct sock *)icsk;
score = nip_tcp_compute_score(sk, net, hnum, daddr, dif, sdif);
if (score > hiscore) {
+6 -12
View File
@@ -48,7 +48,7 @@ static struct hlist_head ninet_addr_lst[NIN_ADDR_HSIZE];
static DEFINE_SPINLOCK(addrconf_hash_lock);
static bool nip_chk_same_addr(struct net *net, const struct nip_addr *addr,
struct net_device *dev);
const struct net_device *dev);
static int nip_get_firstaddr(const struct net_device *dev,
struct nip_addr *addr);
static int nip_addrconf_ifdown(struct net_device *dev, bool unregister);
@@ -251,8 +251,6 @@ static int ninet_addr_add(struct net *net, int ifindex,
struct ninet_dev *idev;
struct net_device *dev;
unsigned long timeout;
clock_t expires;
u32 flags;
__u32 ifa_flags_tmp = ifa_flags;
__u32 valid_lft_tmp = valid_lft;
@@ -271,14 +269,10 @@ static int ninet_addr_add(struct net *net, int ifindex,
return PTR_ERR(idev);
timeout = addrconf_timeout_fixup(valid_lft_tmp, HZ);
if (addrconf_finite_timeout(timeout)) {
expires = jiffies_to_clock_t(timeout * HZ);
if (addrconf_finite_timeout(timeout))
valid_lft_tmp = timeout;
} else {
expires = 0;
flags = 0;
else
ifa_flags_tmp |= IFA_F_PERMANENT;
}
timeout = addrconf_timeout_fixup(preferred_lft, HZ);
if (addrconf_finite_timeout(timeout)) {
@@ -448,7 +442,7 @@ int nip_addrconf_del_ifaddr(struct net *net, void __user *arg)
}
static bool nip_chk_same_addr(struct net *net, const struct nip_addr *addr,
struct net_device *dev)
const struct net_device *dev)
{
unsigned int hash = ninet_addr_hash(addr);
struct ninet_ifaddr *ifp;
@@ -863,7 +857,6 @@ out:
void nip_addr_to_str(const struct nip_addr *addr, unsigned char *buf, int buf_len)
{
int i;
int len = 0;
int total_len = 0;
int addr_num = addr->bitlen / NIP_ADDR_BIT_LEN_8;
@@ -872,7 +865,8 @@ void nip_addr_to_str(const struct nip_addr *addr, unsigned char *buf, int buf_le
total_len = sprintf(buf, "%s", "0x");
for (i = 0; (i < addr_num) && (total_len < buf_len); i++) {
len = sprintf(buf + total_len, "%02x", addr->nip_addr_field8[i]);
int len = sprintf(buf + total_len, "%02x", addr->nip_addr_field8[i]);
if (len <= 0)
break;
total_len += len;
+2 -3
View File
@@ -57,9 +57,7 @@ int nip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
struct nip_addr *nexthop;
struct neighbour *neigh;
int ret = 0;
int res;
struct net_device *dev = skb_dst(skb)->dev;
bool is_v6gw = false;
skb->protocol = htons(ETH_P_NEWIP);
skb->dev = dev;
@@ -73,7 +71,8 @@ int nip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
if (unlikely(!neigh))
neigh = __neigh_create(&nnd_tbl, nexthop, dev, false);
if (!IS_ERR(neigh)) {
res = neigh_output(neigh, skb, is_v6gw);
int res = neigh_output(neigh, skb, false);
rcu_read_unlock_bh();
return res;
}
+4 -4
View File
@@ -63,7 +63,7 @@
static void nndisc_solicit(struct neighbour *neigh, struct sk_buff *skb);
static u32 nndisc_hash(const void *pkey,
const struct net_device *dev, __u32 *fhash_rnd);
const struct net_device *dev, __u32 *hash_rnd);
static bool nndisc_key_eq(const struct neighbour *neigh, const void *pkey);
static int nndisc_constructor(struct neighbour *neigh);
@@ -142,9 +142,9 @@ static u32 nndisc_hash(const void *pkey,
return nndisc_hashfn(pkey, dev, hash_rnd);
}
static bool nndisc_key_eq(const struct neighbour *n, const void *pkey)
static bool nndisc_key_eq(const struct neighbour *neigh, const void *pkey)
{
return neigh_key_eq800(n, pkey);
return neigh_key_eq800(neigh, pkey);
}
static int nndisc_constructor(struct neighbour *neigh)
@@ -217,7 +217,7 @@ unsigned short nip_get_nndisc_send_checksum(struct sk_buff *skb,
}
bool nip_get_nndisc_rcv_checksum(struct sk_buff *skb,
u_char *transport_tail)
const u_char *transport_tail)
{
struct nip_pseudo_header nph = {0};
unsigned short check_len = (unsigned short)(transport_tail - (skb_transport_header(skb)));
+3 -2
View File
@@ -212,7 +212,7 @@ static struct nip_rt_info *nip_rt_pcpu_alloc(struct nip_rt_info *rt)
static struct nip_rt_info *nip_rt_make_pcpu_route(struct nip_rt_info *rt)
{
struct nip_rt_info *pcpu_rt, *prev, **p;
struct nip_rt_info *pcpu_rt, *prev;
pcpu_rt = nip_rt_pcpu_alloc(rt);
if (!pcpu_rt) {
@@ -224,7 +224,8 @@ static struct nip_rt_info *nip_rt_make_pcpu_route(struct nip_rt_info *rt)
rcu_read_lock_bh();
if (rt->rt_pcpu) {
p = this_cpu_ptr(rt->rt_pcpu);
struct nip_rt_info **p = this_cpu_ptr(rt->rt_pcpu);
prev = cmpxchg(p, NULL, pcpu_rt);
if (prev) {
/* If someone did it before us, return prev instead */
-2
View File
@@ -1739,7 +1739,6 @@ void tcp_nip_exit(void)
#define LOG_PRINT_MAX_LEN 256
void nip_dbg(const char *fmt, ...)
{
u32 pos;
char str[LOG_PRINT_MAX_LEN];
va_list args;
s32 ret;
@@ -1748,7 +1747,6 @@ void nip_dbg(const char *fmt, ...)
return;
memset(str, 0, sizeof(str));
pos = strlen(str);
(void)memset(&args, 0, sizeof(va_list));
va_start(args, fmt);
ret = vsnprintf(str, sizeof(str), fmt, args) + 1;
+3 -4
View File
@@ -342,11 +342,11 @@ static __u16 tcp_nip_advertise_mss(struct sock *sk)
struct tcp_sock *tp = tcp_sk(sk);
const struct dst_entry *dst = __sk_dst_get(sk);
int mss = tp->advmss;
int nip_hdr_len;
int nip_mss;
u32 mtu;
if (dst) {
int nip_hdr_len;
int nip_mss;
unsigned int metric = dst_metric_advmss(dst);
if (metric < mss) {
@@ -359,7 +359,6 @@ static __u16 tcp_nip_advertise_mss(struct sock *sk)
&sk->sk_nip_daddr);
nip_hdr_len = nip_hdr_len == 0 ? NIP_HDR_MAX : nip_hdr_len;
nip_mss = mtu - nip_hdr_len - sizeof(struct tcphdr);
if (nip_mss > mss) {
mss = nip_mss;
tp->advmss = mss;
@@ -837,7 +836,7 @@ struct sk_buff *tcp_nip_make_synack(const struct sock *sk, struct dst_entry *dst
int __nip_send_synack(struct request_sock *req, struct sk_buff *skb)
{
struct inet_request_sock *ireq = inet_rsk(req); /* 连接请求块 */
int err = -EFAULT;
int err;
int csummode = CHECKSUM_NONE;
struct nip_addr *saddr, *daddr;
struct nip_hdr_encap head = {0};
+17 -19
View File
@@ -73,7 +73,6 @@ static int nip_udp_compute_score(struct sock *sk, struct net *net,
const struct nip_addr *daddr, unsigned short hnum,
int dif, int sdif)
{
bool dev_match;
int score = 0;
struct inet_sock *inet;
@@ -112,8 +111,8 @@ static int nip_udp_compute_score(struct sock *sk, struct net *net,
/* Check the dev index */
if (sk->sk_bound_dev_if) {
dev_match = dif == sk->sk_bound_dev_if ||
sdif == sk->sk_bound_dev_if;
bool dev_match = dif == sk->sk_bound_dev_if || sdif == sk->sk_bound_dev_if;
if (!dev_match)
return -1;
score++;
@@ -135,12 +134,11 @@ static struct sock *nip_udp_lib_lookup2(struct net *net,
{
struct sock *sk;
struct sock *result = NULL;
int score, badness;
int badness = -1;
badness = -1;
udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
score = nip_udp_compute_score(sk, net, saddr, sport, daddr,
hnum, dif, sdif);
int score = nip_udp_compute_score(sk, net, saddr, sport, daddr, hnum, dif, sdif);
if (score > badness) {
result = sk;
badness = score;
@@ -226,8 +224,8 @@ int nip_udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len)
{
struct sk_buff *skb;
unsigned int ulen, copied, datalen;
int peeking, off;
unsigned int ulen, copied;
int peeking, off, datalen;
int err;
off = sk_peek_offset(sk, flags);
@@ -355,6 +353,13 @@ int nip_udp_output(struct sock *sk, struct msghdr *msg, size_t len)
int err = 0;
struct inet_sock *inet;
if (!sin) {
/* Currently, udp socket Connect function is not implemented.
* The destination address and port must be directly provided by Sendto
*/
return -EDESTADDRREQ;
}
if (sin->sin_family != AF_NINET) {
DEBUG("%s: sin_family false.", __func__);
return -EAFNOSUPPORT;
@@ -365,16 +370,9 @@ int nip_udp_output(struct sock *sk, struct msghdr *msg, size_t len)
}
inet = inet_sk(sk);
if (sin) {
/* Destination address, port (network order) must be specified when sendto */
dport = sin->sin_port;
fln.daddr = sin->sin_addr;
} else {
/* Currently, udp socket Connect function is not implemented.
* The destination address and port must be directly provided by Sendto
*/
return -EDESTADDRREQ;
}
/* Destination address, port (network order) must be specified when sendto */
dport = sin->sin_port;
fln.daddr = sin->sin_addr;
sport = htons(inet->inet_num);
/* Check the dev index */