Lines Matching refs:gwj
397 struct cgw_job *gwj = (struct cgw_job *)data;
403 if (gwj->flags & CGW_FLAGS_CAN_FD) {
428 gwj->deleted_frames++;
432 if (!(gwj->dst.dev->flags & IFF_UP)) {
433 gwj->dropped_frames++;
438 if (!(gwj->flags & CGW_FLAGS_CAN_IIF_TX_OK) &&
439 can_skb_prv(skb)->ifindex == gwj->dst.dev->ifindex)
447 if (gwj->mod.modfunc[0])
453 gwj->dropped_frames++;
461 if (gwj->limit_hops && cgw_hops(nskb) == 1)
462 cgw_hops(nskb) = max_hops - gwj->limit_hops + 1;
464 nskb->dev = gwj->dst.dev;
470 while (modidx < MAX_MODFUNCTIONS && gwj->mod.modfunc[modidx])
471 (*gwj->mod.modfunc[modidx++])(cf, &gwj->mod);
481 gwj->deleted_frames++;
487 if (gwj->mod.csumfunc.crc8)
488 (*gwj->mod.csumfunc.crc8)(cf, &gwj->mod.csum.crc8);
490 if (gwj->mod.csumfunc.xor)
491 (*gwj->mod.csumfunc.xor)(cf, &gwj->mod.csum.xor);
495 if (!(gwj->flags & CGW_FLAGS_CAN_SRC_TSTAMP))
499 if (can_send(nskb, gwj->flags & CGW_FLAGS_CAN_ECHO))
500 gwj->dropped_frames++;
502 gwj->handled_frames++;
505 static inline int cgw_register_filter(struct net *net, struct cgw_job *gwj)
507 return can_rx_register(net, gwj->src.dev, gwj->ccgw.filter.can_id,
508 gwj->ccgw.filter.can_mask, can_can_gw_rcv,
509 gwj, "gw", NULL);
512 static inline void cgw_unregister_filter(struct net *net, struct cgw_job *gwj)
514 can_rx_unregister(net, gwj->src.dev, gwj->ccgw.filter.can_id,
515 gwj->ccgw.filter.can_mask, can_can_gw_rcv, gwj);
528 struct cgw_job *gwj = NULL;
533 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
534 if (gwj->src.dev == dev || gwj->dst.dev == dev) {
535 hlist_del(&gwj->list);
536 cgw_unregister_filter(net, gwj);
538 kmem_cache_free(cgw_cache, gwj);
546 static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj, int type,
558 rtcan->gwtype = gwj->gwtype;
559 rtcan->flags = gwj->flags;
563 if (gwj->handled_frames) {
564 if (nla_put_u32(skb, CGW_HANDLED, gwj->handled_frames) < 0)
568 if (gwj->dropped_frames) {
569 if (nla_put_u32(skb, CGW_DROPPED, gwj->dropped_frames) < 0)
573 if (gwj->deleted_frames) {
574 if (nla_put_u32(skb, CGW_DELETED, gwj->deleted_frames) < 0)
580 if (gwj->limit_hops) {
581 if (nla_put_u8(skb, CGW_LIM_HOPS, gwj->limit_hops) < 0)
585 if (gwj->flags & CGW_FLAGS_CAN_FD) {
588 if (gwj->mod.modtype.and) {
589 memcpy(&mb.cf, &gwj->mod.modframe.and, sizeof(mb.cf));
590 mb.modtype = gwj->mod.modtype.and;
595 if (gwj->mod.modtype.or) {
596 memcpy(&mb.cf, &gwj->mod.modframe.or, sizeof(mb.cf));
597 mb.modtype = gwj->mod.modtype.or;
602 if (gwj->mod.modtype.xor) {
603 memcpy(&mb.cf, &gwj->mod.modframe.xor, sizeof(mb.cf));
604 mb.modtype = gwj->mod.modtype.xor;
609 if (gwj->mod.modtype.set) {
610 memcpy(&mb.cf, &gwj->mod.modframe.set, sizeof(mb.cf));
611 mb.modtype = gwj->mod.modtype.set;
618 if (gwj->mod.modtype.and) {
619 memcpy(&mb.cf, &gwj->mod.modframe.and, sizeof(mb.cf));
620 mb.modtype = gwj->mod.modtype.and;
625 if (gwj->mod.modtype.or) {
626 memcpy(&mb.cf, &gwj->mod.modframe.or, sizeof(mb.cf));
627 mb.modtype = gwj->mod.modtype.or;
632 if (gwj->mod.modtype.xor) {
633 memcpy(&mb.cf, &gwj->mod.modframe.xor, sizeof(mb.cf));
634 mb.modtype = gwj->mod.modtype.xor;
639 if (gwj->mod.modtype.set) {
640 memcpy(&mb.cf, &gwj->mod.modframe.set, sizeof(mb.cf));
641 mb.modtype = gwj->mod.modtype.set;
647 if (gwj->mod.uid) {
648 if (nla_put_u32(skb, CGW_MOD_UID, gwj->mod.uid) < 0)
652 if (gwj->mod.csumfunc.crc8) {
654 &gwj->mod.csum.crc8) < 0)
658 if (gwj->mod.csumfunc.xor) {
660 &gwj->mod.csum.xor) < 0)
664 if (gwj->gwtype == CGW_TYPE_CAN_CAN) {
665 if (gwj->ccgw.filter.can_id || gwj->ccgw.filter.can_mask) {
667 &gwj->ccgw.filter) < 0)
671 if (nla_put_u32(skb, CGW_SRC_IF, gwj->ccgw.src_idx) < 0)
674 if (nla_put_u32(skb, CGW_DST_IF, gwj->ccgw.dst_idx) < 0)
690 struct cgw_job *gwj = NULL;
695 hlist_for_each_entry_rcu(gwj, &net->can.cgw_list, list) {
699 if (cgw_put_job(skb, gwj, RTM_NEWROUTE,
993 struct cgw_job *gwj;
1021 hlist_for_each_entry(gwj, &net->can.cgw_list, list) {
1022 if (gwj->mod.uid != mod.uid)
1026 if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw)))
1031 memcpy(&gwj->mod, &mod, sizeof(mod));
1041 gwj = kmem_cache_alloc(cgw_cache, GFP_KERNEL);
1042 if (!gwj)
1045 gwj->handled_frames = 0;
1046 gwj->dropped_frames = 0;
1047 gwj->deleted_frames = 0;
1048 gwj->flags = r->flags;
1049 gwj->gwtype = r->gwtype;
1050 gwj->limit_hops = limhops;
1053 memcpy(&gwj->mod, &mod, sizeof(mod));
1054 memcpy(&gwj->ccgw, &ccgw, sizeof(ccgw));
1058 gwj->src.dev = __dev_get_by_index(net, gwj->ccgw.src_idx);
1060 if (!gwj->src.dev)
1063 if (gwj->src.dev->type != ARPHRD_CAN)
1066 gwj->dst.dev = __dev_get_by_index(net, gwj->ccgw.dst_idx);
1068 if (!gwj->dst.dev)
1071 if (gwj->dst.dev->type != ARPHRD_CAN)
1076 err = cgw_register_filter(net, gwj);
1078 hlist_add_head_rcu(&gwj->list, &net->can.cgw_list);
1081 kmem_cache_free(cgw_cache, gwj);
1088 struct cgw_job *gwj = NULL;
1093 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
1094 hlist_del(&gwj->list);
1095 cgw_unregister_filter(net, gwj);
1097 kmem_cache_free(cgw_cache, gwj);
1105 struct cgw_job *gwj = NULL;
1142 hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
1143 if (gwj->flags != r->flags)
1146 if (gwj->limit_hops != limhops)
1150 if (gwj->mod.uid || mod.uid) {
1151 if (gwj->mod.uid != mod.uid)
1155 if (memcmp(&gwj->mod, &mod, sizeof(mod)))
1160 if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw)))
1163 hlist_del(&gwj->list);
1164 cgw_unregister_filter(net, gwj);
1166 kmem_cache_free(cgw_cache, gwj);