@@ -948,6 +948,41 @@ static unsigned short batadv_dat_get_vid(struct sk_buff *skb, int *hdr_size)
948948 return vid ;
949949}
950950
951+ /**
952+ * batadv_dat_arp_create_reply - create an ARP Reply
953+ * @bat_priv: the bat priv with all the soft interface information
954+ * @ip_src: ARP sender IP
955+ * @ip_dst: ARP target IP
956+ * @hw_src: Ethernet source and ARP sender MAC
957+ * @hw_dst: Ethernet destination and ARP target MAC
958+ * @vid: VLAN identifier (optional, set to zero otherwise)
959+ *
960+ * Creates an ARP Reply from the given values, optionally encapsulated in a
961+ * VLAN header.
962+ *
963+ * Return: An skb containing an ARP Reply.
964+ */
965+ static struct sk_buff *
966+ batadv_dat_arp_create_reply (struct batadv_priv * bat_priv , __be32 ip_src ,
967+ __be32 ip_dst , u8 * hw_src , u8 * hw_dst ,
968+ unsigned short vid )
969+ {
970+ struct sk_buff * skb ;
971+
972+ skb = arp_create (ARPOP_REPLY , ETH_P_ARP , ip_dst , bat_priv -> soft_iface ,
973+ ip_src , hw_dst , hw_src , hw_dst );
974+ if (!skb )
975+ return NULL ;
976+
977+ skb_reset_mac_header (skb );
978+
979+ if (vid & BATADV_VLAN_HAS_TAG )
980+ skb = vlan_insert_tag (skb , htons (ETH_P_8021Q ),
981+ vid & VLAN_VID_MASK );
982+
983+ return skb ;
984+ }
985+
951986/**
952987 * batadv_dat_snoop_outgoing_arp_request - snoop the ARP request and try to
953988 * answer using DAT
@@ -1005,20 +1040,12 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
10051040 goto out ;
10061041 }
10071042
1008- skb_new = arp_create ( ARPOP_REPLY , ETH_P_ARP , ip_src ,
1009- bat_priv -> soft_iface , ip_dst , hw_src ,
1010- dat_entry -> mac_addr , hw_src );
1043+ skb_new = batadv_dat_arp_create_reply ( bat_priv , ip_dst , ip_src ,
1044+ dat_entry -> mac_addr ,
1045+ hw_src , vid );
10111046 if (!skb_new )
10121047 goto out ;
10131048
1014- if (vid & BATADV_VLAN_HAS_TAG ) {
1015- skb_new = vlan_insert_tag (skb_new , htons (ETH_P_8021Q ),
1016- vid & VLAN_VID_MASK );
1017- if (!skb_new )
1018- goto out ;
1019- }
1020-
1021- skb_reset_mac_header (skb_new );
10221049 skb_new -> protocol = eth_type_trans (skb_new ,
10231050 bat_priv -> soft_iface );
10241051 bat_priv -> stats .rx_packets ++ ;
@@ -1081,25 +1108,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
10811108 if (!dat_entry )
10821109 goto out ;
10831110
1084- skb_new = arp_create (ARPOP_REPLY , ETH_P_ARP , ip_src ,
1085- bat_priv -> soft_iface , ip_dst , hw_src ,
1086- dat_entry -> mac_addr , hw_src );
1087-
1111+ skb_new = batadv_dat_arp_create_reply (bat_priv , ip_dst , ip_src ,
1112+ dat_entry -> mac_addr , hw_src , vid );
10881113 if (!skb_new )
10891114 goto out ;
10901115
1091- /* the rest of the TX path assumes that the mac_header offset pointing
1092- * to the inner Ethernet header has been set, therefore reset it now.
1093- */
1094- skb_reset_mac_header (skb_new );
1095-
1096- if (vid & BATADV_VLAN_HAS_TAG ) {
1097- skb_new = vlan_insert_tag (skb_new , htons (ETH_P_8021Q ),
1098- vid & VLAN_VID_MASK );
1099- if (!skb_new )
1100- goto out ;
1101- }
1102-
11031116 /* To preserve backwards compatibility, the node has choose the outgoing
11041117 * format based on the incoming request packet type. The assumption is
11051118 * that a node not using the 4addr packet format doesn't support it.
0 commit comments